Created
February 24, 2024 08:32
-
-
Save dagenius007/89a9a3954571b2c502d8493a7e6ea7c7 to your computer and use it in GitHub Desktop.
Robotics Assesment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maxArea(height: number[]): number { | |
let i = 0 , j = height.length - 1 , maxA = 0 | |
while(i < j){ | |
let minH = Math.min(height[i] , height[j]) | |
let width = j - 1 | |
maxA = Math.max(maxA , (minH * width)) | |
if(height[j] < height[i]) { | |
j -= 1 | |
}else { | |
i+=1; | |
} | |
} | |
return maxA | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment