It looks like the solution requires O(N*N) complexity, by selecting every pair of indices and computing the amount of water hold by the corresponding container.
But, similiar to the 2-sum problem, this can be solved with 2 pointers moving towards each other. The rule to update the pointers are:
Of course, by using the 2 pointer algorithm, we skip some pairs of indices, we need to prove that those pairs can never produce the maximum product. A proof of contradiction is quite obvious.