Water Container Problem Leetcode Javascript