Widest Tank (Arrays & Lists)

Walls of heights h[0..n-1] stand in a row, one step apart. Pick two walls; with the floor they form a tank that holds water up to the shorter wall. Print the most water a tank can hold (width × shorter height).

Input: n (2 to 1000), then n heights from 0 to 10^4.

Output: One integer.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Start with the widest pair: the two end walls.

More Arrays & Lists practice