DSA · interactive
Two pointers: the container with most water
Pick two lines to hold the most water. Checking every pair is O(n²). Start at both ends and always move the shorter line inward, and one pass is enough. Watch why.
Check 1 of 8
best 8
1L86254837R
Lines 0 and 8: min(1, 7) × 8 = 8. Move the left one, it's the shorter line.
Heights
1 The widest container uses the first and last line. Start there.
L = 0, R = 8
2 3 4 5
Now solve it
In production
Tools and technologies
Two indices walking a sorted sequence is how merge joins and merge sort combine data.
Not tied to one language — use these names when you search docs or design a system.