Loading...
Loading...
Loading...
Customers join a queue and each has a priority number. For every customer, print how many customers behind them have a strictly smaller priority number.
Example 1
Input
5 2 6 1
Output
2 1 1 0
Example 2
Input
3 3 3
Output
0 0 0
Try the problem first. Open one hint at a time.
Counting pairs for each customer one by one is O(n squared).
Use merge sort on the indexes; add counts while merging.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor