Last active
April 12, 2019 10:21
-
-
Save wheatdog/82a5a16ef2045c4cf3ba8ecfb5f2b03d to your computer and use it in GitHub Desktop.
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 is_at_most_one_fixable_non_decreasing(num_list): | |
| for skip_index in range(len(num_list)): | |
| non_decreasing = True | |
| for idx in range(1,len(num_list)): | |
| if non_decreasing == False: | |
| break | |
| if idx == skip_idx: | |
| continue | |
| prev_idx = idx - 1 | |
| if prev_idx == skip_idx: | |
| prev_idx -= 1 | |
| if prev_idx < 0: | |
| continue | |
| if num_list[prev_idx] > num_list[idx]: | |
| non_decreasing = False | |
| if non_decreasing == True: | |
| return True | |
| return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment