heights[i] are wall heights. Write max_water(heights) returning the most water two walls can hold: (distance between them) × (shorter wall). Use two pointers.
max_water([1, 8, 6, 2, 5, 4, 8, 3, 7]) → 49
max_water([1, 1]) → 1
Submit runs 5 tests, including hidden edge cases.
Run your code to see the output here.