diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/single_number.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/single_number.cpp')
-rw-r--r-- | other/single_number.cpp | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/other/single_number.cpp b/other/single_number.cpp deleted file mode 100644 index e9a5878..0000000 --- a/other/single_number.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int singleNumber(vector<int> &nums) { - int ans; - /* - * unordered_map to track frequency - * unordered_map<key data type, value data type> - * both are int in this case. - */ - unordered_map<int, int> freq; - for (int i = 0; i < nums.size(); i++) - /* - * store frequency - * given 4, 1, 2, 1, 2 - * 4 -> once - * 1 -> twice - * 2 -> twice - * output: 4 - */ - freq[nums[i]]++; - for (auto i : freq) // traverse map - if (i.second == 1) { // if frequency of any element is 1... - ans = i.first; // that's the answer - break; // exit loop because we have our answer - } - return ans; - } -}; - -int main() { - vector<int> nums = {4, 1, 2, 1, 2}; - Solution obj; - for (int i = 0; i < nums.size(); i++) - cout << nums[i] << ' '; - cout << endl << obj.singleNumber(nums); -} |