human
Maximum value of | arr [ i ] | Return maximum value of | arr [ i ] - arr [ j ] | + | i - j |.
Iterating two for loop , one for i and another for j ..
Evaluating | arr [ i ] - arr [ j ] | + | i - j | and compare with previous maximum ..
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 ) :
	ans = 0 ;
	for i in range ( n ) :
		for j in range ( n ) :
			ans = ans if ans > ( abs ( arr [ i ] - arr [ j ] ) + abs ( i - j ) ) else ( abs ( arr [ i ] - arr [ j ] ) + abs ( i - j ) ) ;
	return ans ;
arr = [ 1 , 2 , 3 , 1 ] ;
n = len ( arr ) ;
print ( findValue ( arr , n ) ) ;