fork download
  1. # your code goes here
  2. class Solution(object):
  3. def singleNonDuplicate(self, nums):
  4. """
  5. :type nums: List[int]
  6. :rtype: int
  7. """
  8. l = 0
  9. h = len(nums)-1
  10.  
  11. while(l<h):
  12. mid = (l+h)//2
  13. if mid % 2 == 1:
  14. mid = mid-1
  15.  
  16. if nums[mid] == nums[mid+1]:
  17. l = mid + 2
  18. else:
  19. h = mid
  20.  
  21. return nums[l]
  22.  
Success #stdin #stdout 0.06s 13900KB
stdin
Standard input is empty
stdout
Standard output is empty