Dsa
Dynamic Programming
Medium
Water Tank Capacity
You have a water tank represented by an array where each element is the height of the wall at that position. Calculate the maximum volume of water that the tank can hold after it rains.
Input Format:
- A single line containing the heights of the walls as space-separated integers.
Output Format:
- A single integer representing the maximum water capacity.
Example:
Input:
0 1 0 2 1 0 1 3 2 1 2 1
Output:
6
Key concepts
dynamic_programminggreedycapacity
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