Open guodongxiaren opened 4 years ago
https://leetcode-cn.com/problems/single-number/
太简单了。不要用map。O(1)空间全员异或!
class Solution { public: int singleNumber(vector<int>& nums) { int res = 0; for (int n: nums) { res ^= n; } return res; } };
太简单了。不要用map。O(1)空间全员异或!