Last active
June 6, 2021 09:55
-
-
Save jin-x/a266caa8ad8fae56953dbc1bf9544934 to your computer and use it in GitHub Desktop.
@jinxonik / UniLecs #80
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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