Mercurial
view grok_interview/binary_search.py @ 61:9df5587cf23b
[Color game] It can compile on windows now.
| author | June Park <me@mrjunejune.com> |
|---|---|
| date | Sat, 20 Dec 2025 21:07:34 -0500 |
| parents | 68fa88ac73fe |
| children |
line wrap: on
line source
x = [1,2,3,4,5,9,20,25,33,99] # | | target = 18 left = 0 right = len(x) while left < right: mid = (left + right)//2 if x[mid] == target: break elif x[mid] < target: left = mid + 1 else: right = mid print(x[mid])