Loading...
Loading...
Loading...
Prices are kept in ascending order and may repeat. A new price arrives. Print the position where it must be inserted so the list stays sorted, placing it before any equal prices.
Example 1
Input
5 10 20 20 30 40 20
Output
1
Example 2
Input
5 10 20 20 30 40 25
Output
3
Try the problem first. Open one hint at a time.
The answer is the first position whose price is not smaller than p.
The bisect module has a function for exactly this position.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor