human
Replace every element with the greatest element on right side | Function to replace every element with the next greatest element.
Initialize the next greatest element.
The next greatest element for the rightmost element is always - 1.
Replace all other elements with the next greatest.
Store the current element ( needed later for updating the next greatest element ).
Replace current element with the next greatest.
Update the greatest element , if needed.
Utility function to print an array.
Driver function to test above function"
Solution in Python:

=====
Can you provide a code to replace every element with the greatest element on right side and the other steps required?
assistant
#Here is code to replace every element with the greatest element on right side and the other steps required.
 def nextGreatest ( arr ) :
	size = len ( arr )
	max_from_right = arr [ size - 1 ]
	arr [ size - 1 ] = - 1
	for i in range ( size - 2 , - 1 , - 1 ) :
		temp = arr [ i ]
		arr [ i ] = max_from_right
		if max_from_right < temp :
			max_from_right = temp
def printArray ( arr ) :
	for i in range ( 0 , len ( arr ) ) :
		print arr [ i ] ,
arr = [ 16 , 17 , 4 , 3 , 5 , 2 ]
nextGreatest ( arr )
print " Modified ▁ array ▁ is "
printArray ( arr )