Greedy1 [Leetcode][Javascript][Medium] 11. Container With Most Water https://leetcode.com/problems/container-with-most-water/ /** * @param {number[]} height * @return {number} */ var maxArea = function(height) { var p1 = 0, p2 = height.length - 1; var max = {area: 0, height: 0}; while(p1 !== p2) { var minHeight = Math.min(height[p1], height[p2]); var width = p2 - p1; if (minHeight > max.height) { var area = minHeight * width; if (max.area 2021. 7. 4. 이전 1 다음