Solution using XOR. Is there a more efficient way?


  • 0
    S

    public int singleNumber(int[] nums) {
    int val = 0;
    for(int i = 0; i < nums.length; i++){
    val = val ^ nums[i];
    }
    return val;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.