Question bank › Monotonic Stack
Dsa Monotonic Stack Medium

Monotonic Array Product

Given an array of integers, find the product of the nearest greater number on the left side for every element. If no such number exists, return 1 for that element. Example Input: 5 3 1 4 5 2 Example Output: 1 3 3 4 1 Input Format: - The first line contains an integer n (1 ≤ n ≤ 30000), the number of elements. - The second line contains n space-separated integers, representing the array. Output Format: - A single line of n integers representing the product of the nearest greater elements on the left.

Key concepts

monotonic_stackarrayproduct

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.