LeetCode 540. Single Element in a Sorted Array考点难度ArrayMedium题目You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.Return the single element that appears only once.Your solution must run in O(log n) time and O(1) space.思路Before the single element x pairs start at even indices. At/after the single element x this pattern breaks答案classSolution{publicintsingleNonDuplicate(int[]nums){intleft0,rightnums.length-1;while(leftright){intmid(leftright)/2;if((mid%20nums[mid]nums[mid1])||(mid%21nums[mid]nums[mid-1]))leftmid1;elserightmid;}returnnums[left];}}