Java 3-line solution


  • 0
    C
    class Solution {
        public int singleNonDuplicate(int[] nums) {
            int result=nums[0];
            for(int i=1;i<nums.length;i++){result^=nums[i];}
            return result;
        }
    }
    

Log in to reply
 

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