class Solution {
public int singleNumber(int[] nums) {
Set<Integer> set = new HashSet<>();
for(int num : nums){
if(set.contains(num))
set.remove(num);
else
set.add(num);
}
Integer[] array = set.toArray(new Integer[0]);
return array[0];
}
}
leetcode136. 只出现一次的数字
最新推荐文章于 2024-09-27 16:22:58 发布