1299. Replace Elements with Greatest Element on Right Side
Easy
Given an array arr
, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1
.
After doing so, return the array.
Example 1:
Example 2:
Constraints:
1 <= arr.length <= 104
1 <= arr[i] <= 105
解題
Runtime: 17 ms, faster than 88.89%
Memory Usage: 6.3 MB, less than 88.00%
Last updated