signal num一个int数组,里面数值都是成对出现,只有一个是单独的,找出单独者。360ms
public class Solution { public int singleNumber(int[] nums) { int ret = nums[0]; for (int i = 1; i < nums.length; i++) { ret ^= nums[i]; } return ret; } }
public class Solution { public int singleNumber(int[] nums) { int ret = nums[0]; for (int i = 1; i < nums.length; i++) { ret ^= nums[i]; } return ret; } }