Skip to content

Commit 92773a8

Browse files
committed
add js solution for leetcode11
1 parent ca67cb7 commit 92773a8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ LeetCode
401401
|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/)| [js](./algorithms/longestCommonPrefix/longestCommonPrefix.js) |Easy|
402402
|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer/)| |Easy|
403403
|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman/)| |Medium|
404-
|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water/)| |Medium|
404+
|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water/)| [js](./algorithms/containerWithMostWater/containerWithMostWater.js) |Medium|
405405
|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching/)| |Hard|
406406
|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number/)| |Easy|
407407
|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/)| |Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} height
3+
* @return {number}
4+
*/
5+
var maxArea = function(height) {
6+
let ans = 0, L = 0, R = height.length - 1;
7+
while(L <= R) {
8+
const now = Math.min(height[L], height[R]) * (R - L);
9+
ans = Math.max(ans, now);
10+
height[L] > height[R] ? R-- : L++ ;
11+
}
12+
return ans;
13+
};

0 commit comments

Comments
 (0)