CT038

Next-Greater Lantern

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Each lantern's brightness label asks for the first strictly brighter lantern to its right, or -1 if none exists. Task: For each array element, find its nearest greater value to the right. Input format: n; then n integers. Output format: Print n answers separated by spaces. Constraints: 1 <= n <= 200000; values in [-10^9,10^9]

Example 1:

Input: 4 2 1 2 4
Output: 4 2 4 -1

Example 2:

Input: 1 5
Output: -1

Example 3:

Input: 5 5 4 3 2 1
Output: -1 -1 -1 -1 -1

Constraints:

1 <= n <= 200000; values in [-10^9,10^9]

Tags:

stack monotonic-stack
Loading...
Test Cases:No test cases
No test cases available.
Next-Greater Lantern - MEDIUM Coding Problem | CodeTikki