Dsa
Dynamic Programming
Medium
Water Container Problem
Given an array of integers where each integer represents the height of a vertical line drawn at that index, find the maximum volume of water that can be contained between two lines. The volume is determined by the distance between the lines and the height of the shorter line. Print the maximum volume.
Input Format:
- A single line containing space-separated integers representing the heights of the lines (1 <= n <= 10000).
Output Format:
- A single integer representing the maximum water volume.
Example:
Input:
1 8 6 2 5 4 8 3 7
Output:
49
Key concepts
dynamic_programmingtwo_pointersarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now