2
public int singleNonDuplicate(int[] nums) {3
if (nums.length == 1) return nums[0];5
int h = nums.length - 1;8
int mid = l + (h - l) / 2; // divide the array10
if (nums[mid] == nums[mid + 1]) mid = mid - 1; // two same elements should be in same half12
if ((mid - l + 1) % 2 != 0)13
h = mid; // checking the length of left half. If its is odd then update ur right pointer to15
else l = mid + 1; // else your right half will be odd then update your left pointer to mid+118
return nums[l]; // left pointer will have the answer at last