fork download
  1. arr = [0,1,2,3,4,5,6,7,8,8,9]
  2.  
  3. lower, upper = 0, len(arr)
  4. while lower != upper:
  5. mid = (lower + upper) // 2
  6. if arr[mid] >= mid:
  7. lower = mid
  8. else:
  9. upper = mid - 1
  10.  
  11. print(arr[lower])
Success #stdin #stdout 0.02s 5852KB
stdin
Standard input is empty
stdout
8