Two Pointers pattern
Container With Most Water
Given heights representing vertical lines, pick two lines that together with the x-axis form a container holding the most water, and return that maximum area. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 11
- Medium
- 2 approaches
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Two PointersLeetCode 11
Medium
From the first idea to the best one
- 01 Brute force O(n²)O(1) space
- 02 Optimized · two pointers O(n)O(1) space
What you will learn
- How to read Container With Most Water and spot the two pointers pattern in it
- Brute force: O(n²) time, O(1) space
- Optimized · two pointers: O(n) time, O(1) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Two Pointers
See Container With Most Water run, step by step
Sign in and this page opens on the animation, with all 12 Two Pointers problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.