aboutsummaryrefslogtreecommitdiff
path: root/store/works/solutions/leetcode/cpp/260.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'store/works/solutions/leetcode/cpp/260.cpp')
-rw-r--r--store/works/solutions/leetcode/cpp/260.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/store/works/solutions/leetcode/cpp/260.cpp b/store/works/solutions/leetcode/cpp/260.cpp
new file mode 100644
index 0000000..5679d52
--- /dev/null
+++ b/store/works/solutions/leetcode/cpp/260.cpp
@@ -0,0 +1,23 @@
+#include <vector>
+#include <unordered_set>
+
+using std::vector;
+
+class Solution
+{
+public:
+ vector<int> singleNumber(vector<int> &nums)
+ {
+ std::unordered_set<int> s;
+ for (auto i : nums)
+ {
+ const auto result = s.find(i);
+ if (result == s.cend())
+ s.insert(i);
+ else
+ s.erase(result);
+ }
+
+ return vector<int>(s.cbegin(), s.cend());
+ }
+};