Question bank › Monotonic Stack
Dsa Monotonic Stack Easy

Next Greater Element to the Right

Given a list of integers, return a new list where each element at index i is replaced by the first greater element to the right of i in the original list. If no such element exists, replace it with -1. Input Format: - A single line containing n integers, separated by spaces. Output Format: - A single line containing n integers, separated by spaces. Example: Input: 4 5 2 10 8 Output: 5 10 10 -1 -1

Key concepts

monotonic_stackarraysiteration

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.