Pick two vertical lines that, with the x-axis, form a container holding the most water: area = min(height[l], height[r]) × (r − l). Two approaches, same problem — switch between them and watch how time trades off.
area = min(height[l], height[r]) × (r − l)