Loading...
Loading...
Loading...
Delivery slots are sorted from earliest to latest and are all different. Report the position (from 0) of a requested slot, or -1 if it is not in the list.
Example 1
Input
5 10 20 30 40 50 40
Output
3
At position 3.
Example 2
Input
5 10 20 30 40 50 35
Output
-1
Try the problem first. Open one hint at a time.
The list is sorted, so look at the middle and throw away half each time.
Keep two ends, lo and hi, and stop when lo passes hi.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor