Leetcode 3072. Distribute Elements Into Two Arrays II
Process nums left-to-right to build arr1 and arr2: for each nums[i], append it to the array that currently has fewer elements strictly greater than nums[i] (ties broken by smaller length, then arr1), and return arr1 concatenated with arr2. The key challenge is maintaining dynamic counts of elements greater than a value in each multiset efficiently to support large n.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.