Single Element in a Sorted Array

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.

Constraints

  • 1 <= nums.length <= 100000
  • 0 <= nums[i] <= 100000
Saving… · 2 lines
class Solution:
def findSingleElement(self, nums: List[int]) -> int:
Console

Click Run to execute sample tests.