Adagrad AI interview question

Leetcode question no. 11 (water container)