human
Give me a code to maximum value of and the other steps required given the following:
Maximum value of | arr [ i ] | Return maximum | arr [ i ] - arr [ j ] | + | i - j |.
Calculating first_array and second_array.
Finding maximum and minimum value in first_array.
Storing the difference between maximum and minimum value in first_array.
Finding maximum and minimum value in second_array.
Storing the difference between maximum and minimum value in second_array.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to maximum value of and the other steps required.
 def findValue ( arr , n ) :
	a = [ ]
	b = [ ]
	for i in range ( n ) :
		a . append ( arr [ i ] + i )
		b . append ( arr [ i ] - i )
	x = a [ 0 ]
	y = a [ 0 ]
	for i in range ( n ) :
		if ( a [ i ] > x ) :
			x = a [ i ]
		if ( a [ i ] < y ) :
			y = a [ i ]
	ans1 = ( x - y )
	x = b [ 0 ]
	y = b [ 0 ]
	for i in range ( n ) :
		if ( b [ i ] > x ) :
			x = b [ i ]
		if ( b [ i ] < y ) :
			y = b [ i ]
	ans2 = ( x - y )
	return max ( ans1 , ans2 )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 1 ]
	n = len ( arr )
	print ( findValue ( arr , n ) )