You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.
Note: Your solution should run in O(log n) time and O(1) space.
給你一個整理過的陣列,其元素只包含出現兩次的整數和只有一個只出現一次的整數。找到那個單獨只出現一次的元素。
注意:
你的答案應該在O(log n)的時間複雜度和O(1)的空間複雜度之中。
終止條件起始等於終點
即可。LeetCode
C++