Java | Leetcode Java题解之第540题有序数组中的单一元素
题目:
题解:
class Solution {public int singleNonDuplicate(int[] nums) {int low = 0, high = nums.length - 1;while (low < high) {int mid = (high - low) / 2 + low;mid -= mid & 1;if (nums[mid] == nums[mid + 1]) {low = mid + 2;} else {high = mid;}}return nums[low];}
}