42. Trapping Rain Water – Solution [Brute-Force to Best]
Here’s the question link on LeetCode 42. Trapping Rain Water: https://leetcode.com/problems/trapping-rain-water/description Brute Force O(n²)Better O(n)Another Approach: Monotonic Stack O(n)Optimal O(n) Brute Force O(n²) For every index, I need to figure…