Dec-01-2020, 07:05 PM
(This post was last modified: Dec-01-2020, 07:25 PM by deanhystad.)
I'm guessing you have a typo? I just ran with target = 111 and got
If I type -111 I get
Output:Greatest number less than 111 is at position 5 with value 102
What are you using for data? I used1 |
sorted_list = [ 1 , 2 , 5 , 6 , 100 , 102 , 110 , 140 , 145 ] |
Output:Greatest number less than -111 is at position -1 with value 145
But the demo does warn to be on the lookout for index == -1.