By ^oring - Java


  • 2
    M
    public class Solution {
        public int singleNumber(int[] nums) {
         int res = 0;
         for(int i = 0; i < nums.length; i++){
            res ^= nums[i];
         }  
         return res;
        }
    }

Log in to reply
 

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