Skip to content

Instantly share code, notes, and snippets.

@jin-x
Last active June 6, 2021 09:55
Show Gist options
  • Save jin-x/a266caa8ad8fae56953dbc1bf9544934 to your computer and use it in GitHub Desktop.
Save jin-x/a266caa8ad8fae56953dbc1bf9544934 to your computer and use it in GitHub Desktop.
@jinxonik / UniLecs #80
def bin_search_check(arr):
min_el = max_el = last = None
for el in arr:
if last != None:
if (min_el != None and el < min_el) or (max_el != None and el > max_el): return False
if el < last: max_el = last
if el >= last: min_el = last
last = el
return True
for arr in ((8,3,6,4), (8,4,6,3)):
print(bin_search_check(arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment