Given heights of vertical lines at positions 0..n-1, choose two lines that, with the x-axis, hold the most water. The area is min(h[i], h[j]) * (j - i). Return the maximum area in O(n).
#two-pointers#greedy2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit