Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

height =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Use two pointers at both ends; the limiting height is the smaller side.

Approach

Compute area = min(height[l], height[r]) * (r-l). Move the pointer on the smaller height inward.

Why it works

Moving the taller side cannot increase min-height, while it always decreases width; only moving the shorter side can possibly increase min-height.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Use two pointers at both ends; the limiting height is the smaller side.

Approach

Compute area = min(height[l], height[r]) * (r-l). Move the pointer on the smaller height inward.

Why it works

Moving the taller side cannot increase min-height, while it always decreases width; only moving the shorter side can possibly increase min-height.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)