Replace With Greatest on the Right
Return a new list where each position holds the largest value found strictly to its right in arr. The last position has nothing to its right, so use -1 there.
Example 1
arr [17,18,5,4,6,1]
returns [18,6,6,6,1,-1]
Right of 17 the largest is 18; right of 18 it is 6; ... the last is -1.
Example 2
arr [400]
returns [-1]
Only the last position, so [-1].
Constraints
1 <= len(arr) <= 401 <= arr[i] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.