(简单题 逻辑位运算)leetcode 136只出现一次的数

按照异或运算的性质,a^0=a,a^a=0,a ^ b ^ c <=> a ^ c ^ b

评论区大佬:

var a = [2,3,2,4,4]

2 ^ 3 ^ 2 ^ 4 ^ 4等价于 2 ^ 2 ^ 4 ^ 4 ^ 3 => 0 ^ 0 ^3 => 3

int singleNumber(int* nums, int numsSize) {
    int result=0;
    int i;
    for(i=0;i

遍历数组每个数

你可能感兴趣的:(leetcode,算法,数据结构)