Maximum water that can be stored between two buildings | Return the maximum water that can be stored ; Check all possible pairs of buildings ; Maximum so far ; Driver code
def maxWater ( height , n ) : NEW_LINE INDENT maximum = 0 ; NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT current = min ( height [ i ] , height [ j ] ) * ( j - i - 1 ) ; NEW_LINE maximum = max ( maximum , current ) ; NEW_LINE DEDENT DEDENT return maximum ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT height = [ 2 , 1 , 3 , 4 , 6 , 5 ] ; NEW_LINE n = len ( height ) ; NEW_LINE print ( maxWater ( height , n ) ) ; NEW_LINE DEDENT