Loading...
Loading...
Loading...
Vertical walls stand along a line, each with a height. Choose two walls. The water held between them has width equal to the distance between the walls and height equal to the shorter wall. Print the largest amount of water.
Example
Input
1 8 6 2 5 4 8 3 7
Output
49
Walls of height 8 and 7 are 7 apart: 7 * 7 = 49.
Try the problem first. Open one hint at a time.
Start with the widest pair of walls.
Move the pointer at the shorter wall, because a shorter wall cannot give more water with a smaller width.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor