Loading...
Loading...
Loading...
Order ids are stored in increasing order with no repeats. Read the ids and one target id. Print the position (counting from 0) of the target, or -1 if it is not in the list.
Example
Input
5 10 20 30 40 50 40
Output
3
Try the problem first. Open one hint at a time.
Keep a window lo..hi and look at the middle id. Move lo or hi past the middle depending on which side the target is on.
Stop when lo passes hi. That means the target is not there.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor