Skip to content

Commit 719ef23

Browse files
committed
fix: add equal height case handling in Largest container
1 parent d3c08ec commit 719ef23

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

java/Two Pointers/LargestContainer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ public int largestContainer(int[] height) {
1111
// If both lines have the same height, move both pointers inward.
1212
if (height[left] < height[right]) {
1313
left++;
14+
} else if (height[left] > height[right]) {
15+
right--;
1416
} else {
17+
left++;
1518
right--;
1619
}
1720
}

0 commit comments

Comments
 (0)