CT213

Leaders on the Mountain Trail

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

A marker is visible only if it is strictly taller than every marker ahead. Task: Print values strictly greater than every value to their right, preserving original order. The last value is always included. Input format: n followed by n integers. Output format: Leader values separated by spaces. Constraints: 1 <= n <= 100000; -10^9 <= a[i] <= 10^9 Edge rules: Apply the stated zero, tie, boundary, and ordering conventions exactly.

Example 1:

Input: 1 5
Output: 5

Example 2:

Input: 1 -3
Output: -3

Example 3:

Input: 5 4 1 9 -2 6
Output: 9 6

Constraints:

1 <= n <= 100000; -10^9 <= a[i] <= 10^9

Tags:

arrays suffix-scan
Loading...
Test Cases:No test cases
No test cases available.