mediumTwo PointersPattern: Mixed

Container With Maximum Volume Solution

Problem Statement

Given a list of non-negative integers `heights` representing the heights of a set of bars with unit width, find the maximum area of water that can be trapped between any two bars. The area of water between two bars `i` and `j` is calculated as the product of the minimum height between `heights[i]` and `heights[j]` and the distance `j - i`.

Constraints

  • The input will be a string where each substring contains the height and width of a building in the format "width:height".
Time: O(n log n) Space: O(n)
Analyze constraints and compute optimal solutions step-by-step.

Run, Test & Submit Code

Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.

Solve on Interactive Workspace

Tested Solutions

No solution code is currently loaded.
Complete this code in the workspace editor.