Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit69dd4c9

Browse files
authored
Merge pull requestneetcode-gh#19 from thuanle123/main
Added 11 Container With Most Water and 55 Jump Game Java
2 parents8b37fb1 +7747508 commit69dd4c9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
classSolution {
2+
publicintmaxArea(int[]height) {
3+
intleft =0;
4+
intright =height.length -1;
5+
intres =0;
6+
while (left <right) {
7+
intcontainerLength =right -left;
8+
intarea =containerLength *Math.min(height[left],height[right]);
9+
res =Math.max(res,area);
10+
if (height[left] <height[right]) {
11+
left++;
12+
}else {
13+
right--;
14+
}
15+
}
16+
returnres;
17+
}
18+
}

‎java/55-Jump-Game.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
classSolution {
2+
publicbooleancanJump(int[]nums) {
3+
intgoal =nums.length-1;
4+
for (inti =nums.length-2;i >=0;i--) {
5+
if (nums[i] +i >=goal) {
6+
goal =i;
7+
}
8+
}
9+
returngoal ==0;
10+
}
11+
}
12+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp