【LeetCode100】--- 96.只出现一次的数字【思维导图+复习回顾】
题目传送门


代码实现
class Solution {public int singleNumber(int[] nums) {int ret = 0;for(int num : nums){ret ^= num;}return ret;}
}
复杂度分析
时间复杂度:
O(n),其中n是数组nums的长度。空间复杂度:
O(1)(常数级空间)


class Solution {public int singleNumber(int[] nums) {int ret = 0;for(int num : nums){ret ^= num;}return ret;}
}
时间复杂度:
O(n),其中n是数组nums的长度。空间复杂度:
O(1)(常数级空间)