items that need to go on a shelf. Some codes have a priority, given as an array order with no repeats, and every code in order appears in items at least once.
Arrange items as follows:
- first come the codes from order, in the order they are listed in order (equal codes stand together);
- then all codes that are not in order, in increasing order.
Return the resulting array.items=[5, 1, 7, 5, 3, 0, 1, 9], order=[7, 1, 5] → [7, 1, 1, 5, 5, 0, 3, 9]
All 7s come first, then all 1s, then the 5s. The values 0, 3 and 9 are not in order, so they go last in increasing order.
items=[4, 2, 4], order=[2, 4] → [2, 4, 4]
order are distinctorder appears in itemsitems=[5, 1, 7, 5, 3, 0, 1, 9], order=[7, 1, 5]
[7, 1, 1, 5, 5, 0, 3, 9]
Run checks the first 3 tests in your browser. Submit checks all 129 tests on the server, hidden ones included.