1299. Replace Elements with Greatest Element on Right Side
Python
class Solution:
def replaceElements(self, arr: List[int]) -> List[int]:
length = len(arr)
if length == 1:
return [-1]
for i in range(0, length-1):
arr[i] = max(arr[i+1:])
arr[length-1] = -1
return arr