本文共 196 字,大约阅读时间需要 1 分钟。
思路:异或计算。0^a=a;a^b=b^a。
public class Solution { public int singleNumber(int[] nums) { int answer=0; for (int i = 0; i < nums.length; i++) { answer^=nums[i]; } return answer; }}
转载地址:http://pushb.baihongyu.com/