Dsa
Monotonic Stack
Easy
Next Greater Office
You are given a list of employees' productivity scores in a large corporation for a week. Each employee has a score that represents their performance on a specific day. Your task is to determine, for each employee, the next day where they will have a higher productivity score than they did on the current day. If there isn't such a day, output -1 for that employee.
Input Format:
- A single line containing space-separated integers representing the productivity scores for the week (0 <= score <= 100).
Output Format:
- A single line containing space-separated integers indicating the next days' higher productivity scores or -1 if no such day exists.
Example:
Input:
50 70 60 80 50 90 40
Output:
70 80 80 90 90 -1 -1
Key concepts
monotonic_stackarraymaximum
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