This is a verified interview question from De-shaw. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Collecting Files" covers key patterns like Other.
"In an office, there is a stack of files arranged in a line, each with an importance level. Each stack is numbered consecutively from 1 to n, with their importance increasing as the number increases. An office employee is tasked with collecting these stack of files and delivering them to the manager's desk. To ensure the process is smooth and efficient, the employee follows this strategy: 1. The employee picks up the leftmost stack. 2. The employee moves to the next stack on the right. 3. The employee picks up the stack if its importance is strictly less than the last file they picked up. 4. Repeat step 2 until there are no more stacks to the right. 5. The employee places all the collected stacks on the manager's desk and returns to step 1 until all stacks are collected. Each trip from left to right to collect files is called a "round." Determine the list of files the employee collects during each round.  ### Constraints - 1 <= n <= 3 * 10^5 - Res[i] <= n"
Join thousands of developers practicing for De-shaw.