Leetcode – 42. Trapping Rain Water

There’s one thing common between this problem and the Container With Most Water problem and that is the height of the shorter tower dictates the result. In this problem, the amount of water that can accumulate between two towers is limited by the height of the shorter tower.  Consider an array [4, 5, 9, 7 ,1, 0 ,4, 0 ,8 …

Mohit AthwaniLeetcode – 42. Trapping Rain Water

Leetcode – 11. Container With Most Water

From the description of the problem, we are told that each number in the array represents the height of the vertical line at that index. So given an array [4, 3, 7, 8, 2, 6, 9, 5], a visual representation of this array would look something like: | | | | | | | | | | | | | …

Mohit AthwaniLeetcode – 11. Container With Most Water