This is a verified interview question from Imoib. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Lexicographically Largest Array - Imoib IITBHU" covers key patterns like Other.
"### Problem Given an array `arr` of size `n`, repeatedly perform the following until the array becomes empty: 1. Choose an integer `k` such that `1 <= k <= current length of arr`. 2. Compute the MEX of the first `k` elements. 3. Append this MEX to `result`. 4. Remove the first `k` elements from `arr`. Return the lexicographically largest possible `result` array. ### Definitions - MEX: Smallest non-negative integer missing from a set. - `MEX({1,2,3}) = 0` - `MEX({0,1,2,4,5}) = 3` - Lexicographically larger: - At the first differing position, larger value wins. - If one array is a prefix of another, the longer array is larger. ### Example `n = 4` `arr = [0,1,1,0]` `k = 2 => MEX({0,1}) = 2` `arr = [1,0] ` `result = [2] ` `k = 2 => MEX({1,0}) = 2` `arr = [] ` `result = [2,2] ` ### Constraints - `1 <= n <= 100`"
Join thousands of developers practicing for Imoib.