1 class Solution { 2 public: 3 /** 4 * @param nums: a vector of integers 5 * @return: an integer 6 */ 7 int findMissing(vector<int> &nums) { 8 // write your code here 9 int n = nums.size(); 10 int number = 0; 11 for (int i = 0; i <= n; i++) 12 number ^= i; 13 for (int i = 0; i < n; i++) 14 number ^= nums[i]; 15 return number; 16 } 17 };
时间: 2024-10-12 17:57:52