human
Trapping Rain Water | Function to return the maximum water that can be stored.
To store the maximum water that can be stored.
For every element of the array.
Find the maximum element on its left.
Find the maximum element on its right.
Update the maximum water.
Driver code"
Solution in Python:
 Can you provide a code to trapping Rain Water and the other steps required?
assistant
#Here is code to trapping Rain Water and the other steps required.
 def maxWater ( arr , n ) :
	res = 0 ;
	for i in range ( 1 , n - 1 ) :
		left = arr [ i ] ;
		for j in range ( i ) :
			left = max ( left , arr [ j ] ) ;
		right = arr [ i ] ;
		for j in range ( i + 1 , n ) :
			right = max ( right , arr [ j ] ) ;
		res = res + ( min ( left , right ) - arr [ i ] ) ;
	return res ;
if __name__ == " _ _ main _ _ " :
	arr = [ 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 ] ;
	n = len ( arr ) ;
	print ( maxWater ( arr , n ) ) ;