136. Single Number
Given an array of integers, every element appearstwice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
使用map:
public int singleNumber(int[] nums) {
int i = 0;
int j = nums.length - 1;
Map<Integer, Integer> map = new HashMap<>();
while (i <= j) {
if (map.containsKey(nums[i]))
map.put(nums[i], map.get(nums[i])+1);
else
map.put(nums[i], 1);
i++;
}
i = 0;
while (i <= j) {
if (map.get(nums[i]) &#