Problem
You're given an array h where h[i] is the height of a vertical bar at position i. Choose two bars; together with the x-axis they form a container whose water holds min(h[a], h[b]) × (b − a). Return the maximum water any pair can hold.
Examples
Input: h = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Output: 49
Bars 8 and 7, 7 apart: min(8, 7) × 7 = 49.
Input: h = [1, 1]
Output: 1
Hints
Try it first. Every hint reveals a bit more.