[Leetcode] Replace Elements with Greatest Element on Right Side

Problem:

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:

Input: arr = [17,18,5,4,6,1]
Output: [18,6,6,6,1,-1]

Solution:

class Solution(object):
def replaceElements(self, arr):
"""
:type arr: List[int]
:rtype: List[int]…