Simple java NonBinarySearch Solution


  • 0
    H
        public int singleNonDuplicate(int[] nums) {
    		int i=0;
    		while( i<nums.length){
    			if( i+1<nums.length && nums[i]==nums[i+1])
    				i=i+2;
    			else 
    				return nums[i];	
    		}
    		return -1;
    	}
    

Log in to reply
 

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