A PHP Error was encountered

Severity: Notice

Message: Undefined index: markdown

Filename: models/Languages.php

Line Number: 60

Backtrace:

File: /var/www/stikked/htdocs/application/models/Languages.php
Line: 60
Function: _error_handler

File: /var/www/stikked/htdocs/application/models/Pastes.php
Line: 516
Function: code_to_description

File: /var/www/stikked/htdocs/application/controllers/Main.php
Line: 693
Function: getPaste

File: /var/www/stikked/htdocs/index.php
Line: 315
Function: require_once

Single Element in a Sorted Array (LeetCode 540) - Stikked

Single Element in a Sorted Array (LeetCode 540)

From linkjob, 1 Week ago, written in , viewed 14 times.
URL https://paste.t1ip.com/view/361f0315 Embed
Download Paste or View Raw
  1. # Single Element in a Sorted Array (LeetCode 540)
  2.  
  3. Binary search pairing even indices.
  4.  
  5. ```python
  6. def singleNonDuplicate(nums):
  7.     lo, hi = 0, len(nums)-1
  8.     while lo < hi:
  9.         m = (lo+hi)//2
  10.         if m%2: m -= 1
  11.         if nums[m]==nums[m+1]: lo = m+2
  12.         else: hi = m
  13.     return nums[lo]
  14. ```
  15.  
  16. Practice on [Linkjob AI copilot](https://www.linkjob.ai/coding-interview-copilot/).
  17.  
  18. (Affiliation: I work on Linkjob AI.)
  19.  

Reply to "Single Element in a Sorted Array (LeetCode 540)"

Here you can reply to the paste above