Replace Elements with Greatest on Right
Easy
Arrays
Array
Replace each element with the greatest among elements to its right. Last element becomes -1.
Constraints
1 ≤ len ≤ 10^4
Examples
Example 1:
Input: 17 18 5 4 6 1
Output: 18 6 6 6 1 -1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console