Container with Most Water | Javascript code for Max Water Container ; Calculating the max area ; Driver code
function maxArea ( A , len ) { let area = 0 ; for ( let i = 0 ; i < len ; i ++ ) { for ( let j = i + 1 ; j < len ; j ++ ) { area = Math . max ( area , Math . min ( A [ j ] , A [ i ] ) * ( j - i ) ) ; } } return area ; } let a = [ 1 , 5 , 4 , 3 ] ; let b = [ 3 , 1 , 2 , 4 , 5 ] ; let len1 = a . length ; document . write ( maxArea ( a , len1 ) + " " ) ; let len2 = b . length ; document . write ( maxArea ( b , len2 ) ) ;