Array Reduction Algorithm
Problem Overview
- Task: Given array arr, repeatedly pick k (1..len), append MEX of first k to result, delete those k; find the lexicographically maximum result.
- Inputs/Outputs and constraints: n integers, 0 ≤ arr[i] ≤ n, 1 ≤ n ≤ 1e5; output the lexicographically greatest result sequence.
- Context: Array reduction problem with MEX (smallest missing non-negative) and lexicographic order; common coding interview topic.
- Company: Snowflake interviews; framed as a Hackerland developer interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
