Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Next Greater Weight

You are given a list of weights of boxes. For each box, determine the weight of the next box that is heavier. If there is no heavier box available, output -1 for that box. Input: A single line containing space-separated integers representing the weights of the boxes. Output: A single line containing space-separated integers representing the weights of the next heavier box. Example: Input: 1 3 2 4 5 1 6 7 Output: 3 4 4 5 6 6 -1

Key concepts

monotonic_stackarrayweight

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.