public int maxArea(int[] height) {
int answer = 0;
int start = 0, end = height.length-1;
while (start < end) {
answer = Math.max((end-start)*Math.min(height[start], height[end]), answer);
if (height[start] < height[end]) {
start++;
} else {
end--;
}
}
return answer;
}
'알고리즘 공부 > Leetcode' 카테고리의 다른 글
[Tree] Unique Binary Search Trees II (0) | 2022.04.06 |
---|---|
[Tree] Binary Tree Inorder Traversal (0) | 2022.03.30 |
[Array] Median of Two Sorted Arrays (0) | 2022.03.29 |