Next Greater Element (Right)

JavaScript Medium 6 views
Back to Questions

Problem Description

For each element, find the next greater element on its right side. If none, print -1 at that position.

Input Format

One line: n then n integers.

Output Format

One line: n integers.

Sample Test Case

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

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next