values. Rearrange it so that rarer numbers come first: all numbers that occur once, then those that occur twice, and so on. Copies of the same number stay together.
If two different numbers occur the same number of times, the larger one comes first.
Return the rearranged array.values=[4, 9, 4, 7, 9, 4] → [7, 9, 9, 4, 4, 4]
7 appears once, 9 twice and 4 three times, so 7 goes first, then both 9s, then the three 4s.
values=[-2, 5, 3, 5, -2, 3] → [5, 5, 3, 3, -2, -2]
All three numbers appear twice, so they go in decreasing order: 5, 3, -2.
values=[4, 9, 4, 7, 9, 4]
[7, 9, 9, 4, 4, 4]
Run checks the first 3 tests in your browser. Submit checks all 116 tests on the server, hidden ones included.