← All problems

Container With Most Water

Medium arraystwo-pointersgreedy LeetCode ↗
Given heights, find two lines forming the container holding the most water.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(1)

Common pitfalls

  • Moving the taller pointer (loses the proof)
  • Forgetting width shrinks each step

Your solution

Log in to save your code and track progress.