Question bank › Monotonic Stack
Dsa Monotonic Stack Medium

Next Smaller Element Index

Given an array of integers, return an array of indices where each index points to the next smaller element in the array. If no smaller element exists on the right, place -1. Input format: - A single line containing space-separated integers. Output format: - A single line containing space-separated integers representing the indices of the next smaller elements. Example: Input: 4 5 2 10 8 Output: 2 2 4 -1 -1

Key concepts

monotonic_stackindicesarrays

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.