Simply XOR everyone


  • 0
    E
    class Solution {
        public int singleNumber(int[] nums) {
            int magic = 0;
            for (int i : nums) magic = magic ^ i;
            return magic;
        }
    }
    

Log in to reply
 

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