Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions java/11-Container-With-Most-Water.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution {
public int maxArea(int[] height) {
int left = 0;
int right = height.length - 1;
int res = 0;
while (left < right) {
int containerLength = right - left;
int area = containerLength * Math.min(height[left], height[right]);
res = Math.max(res, area);
if (height[left] < height[right]) {
left++;
} else {
right--;
}
}
return res;
}
}
12 changes: 12 additions & 0 deletions java/55-Jump-Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public boolean canJump(int[] nums) {
int goal = nums.length-1;
for (int i = nums.length-2; i >= 0; i--) {
if (nums[i] + i >= goal) {
goal = i;
}
}
return goal == 0;
}
}