🏆 C++ || Counter || Easy Approach and Explanation
\uD83D\uDC68\u200D\uD83D\uDCBB Friend\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that motivates me to create a better post li
\uD83D\uDC68\u200D\uD83D\uDCBB Friend\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that motivates me to create a better post like this \u270D\uFE0F\n____________________________________________________________________________________________________________\n____________________________________________________________________________________________________________\n\n#### \u2714\uFE0F **Question Conclusion**\n* Return the vector of the lonely numbers whose adjacent or copy numbers  are not present in the given vector.\n#### \u2714\uFE0F **Solution - I (Easy Approach)**\n##### **Intuition :-**\n* Just mark the count of every element.\n* Check weather its any adjacent no is present in the count array or the number appears more than one.\n* If none of the condition satisfy add the element in the ans vector.\n##### **Code :-**\n```\nclass Solution\n{\npublic:\n     vector<int> findLonely(vector<int> &nums)\n     {\n          vector<int> mark(1000001);\n          for (auto &&num : nums)\n               mark[num]++;\n          vector<int> ans;\n          for (auto &&num : nums)\n               if (num == 0 and !(mark[num + 1] or mark[num] > 1))\n                    ans.push_back(num);\n               else if (num == 1000000 and !(mark[num - 1] or mark[num] > 1))\n                    ans.push_back(num);\n               else if ((num > 0 and num < 1000000) and !(mark[num - 1] or mark[num] > 1 or mark[num + 1]))\n                    ans.push_back(num);\n          return ans;\n     }\n};\n```\n**Time Complexity** : `O(N)`, Iteration is done two times.\n**Space Complexity** : `O(10^6)`, creater a counter vector with maximum size.\n_____________________________________________________________________________________________________________\n_____________________________________________________________________________________________________________\n\n\uD83D\uDCBBIf there are any suggestions/questions in my post, comment below \uD83D\uDC47
['C']