Algorithm · Point72 · Easy
(This problem is a variant of LeetCode 1636 – Sort Array by Increasing Frequency. If you haven't solved that one yet, tackle it first.) Given an integer array items, reorder it so that elements with lower frequency appear earlier. When two values share the same frequency, arrange them in ascending order. Constraints: 1 ≤ items.length ≤ 2 × 10 5 1 ≤ items[i] ≤ 10 6 Example 1: Input: items = [8, 5, 5, 5, 5, 1, 1, 1, 4, 4] Output: [8, 4, 4, 1, 1, 1, 5, 5, 5, 5] Explanation:…
Checking your access…