Back to Problem Roadmap37 Masterclass Curricula
Curated Algorithmic Masterclasses
Masterclass Knowledge Tree
Explore the 37 architectural patterns that govern 95% of FAANG technical interviews. Follow the central knowledge trunk to de-templatize problems from first principles.
Interactive Invariant State MachineContainer With Most Water • Two Pointers Invariant
< Two Pointers/Container With Most WaterMedium
3/4 Steps
left
right
0
1
2
3
4
5
6
7
8
Current Area
49
Max Area
49
CodeExplanation
1while (left < right) {
2 const height = Math.min(height[left], height[right]);
3 const area = height * (right - left);
4 maxArea = Math.max(maxArea, area);
5 if (height[left] < height[right]) {
6 left++;
7 } else {
8 right--;
9 }
10}
Step 3/4
Calculate Area
Left at 1 (height 8), Right at 8 (height 7). Area = min(8, 7) × (8 - 1) = 7 × 7 = 49. New maximum area!
Loading masterclass tree graph...