Loading...
Loading...
Loading...
A store has a preferred order of product codes. Print the sold codes so that codes in the preferred list come first, in the preferred order, with every sale repeated. The codes not in the list follow in increasing order.
Example 1
Input
2 3 1 3 2 4 6 7 9 2 19 2 1 4 3 9 6
Output
2 2 2 1 4 3 3 9 6 7 19
Example 2
Input
5 5 1 7
Output
1 5 5
Try the problem first. Open one hint at a time.
Count how often each code was sold.
Write the preferred codes first, then sort whatever is left.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor