Question bank › Stack
Dsa Stack Medium

Reconstruct Stack from Pop Sequence

Given a sequence of integers that represents the pop order of a stack, reconstruct the sequence of push operations that would yield this pop order. The stack can only contain unique integers during its operation. Input Format: A single line containing space-separated integers representing the pop sequence. Output Format: Print the original sequence of push operations in the order they would have been pushed, space-separated. Example: Input: 4 3 7 5 6 8 Output: 1 2 3 4 5 6 7 8

Key concepts

stackreconstructionsequence

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.