Monotonic stack: For every nums index, return the first strictly greater value appearing to its right, or -1 if no such value exists.
Input: A JSON object { "nums": number[] }.
Output: A JSON number[] with the same length and one next-greater value per input index.
Constraints:
- 0 <= nums.length <= 100000
- Equal values are not strictly greater
- Preserve input index order in the result
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: EASY. Variant: 16. Balance correctness, maintainability, and clear review-ready code.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked easy difficulty.
The signed-in workspace provides the tools required by the round, such as recording, code executi