Skip to content

Commit d01f1bc

Browse files
committed
0042-trapping-rain-water-2.md Reworded.
1 parent a85d732 commit d01f1bc

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ After finishing one category of questions, you can study another category to imp
6767
- [739. Daily Temperatures](problems/0739-daily-temperatures.md)
6868
- [496. Next Greater Element I](problems/0496-next-greater-element-i.md)
6969
- [42. Trapping Rain Water](problems/0042-trapping-rain-water.md)
70-
- [84. Largest Rectangle in Histogram](0084-largest-rectangle-in-histogram.md)
70+
- [84. Largest Rectangle in Histogram](problems/0084-largest-rectangle-in-histogram.md)
7171

7272
More LeetCode problems will be added soon...

problems/0042-trapping-rain-water-2.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ This problem can be solved using **Monotonic Stack**.
3333
### Solution 2
3434
This solution will follow **Monotonic Stack**'s common rule: **only calculating when `pop()` is happening**.
3535

36-
This common rule can be applied to calculating result for most of the **Monotonic Stack** problems.
37-
38-
Sometimes it could be hard to understand, but it does work.
36+
This common rule can be applied to calculating result for **most** of the **Monotonic Stack** problems.
3937

4038
![](../images/0042.png)
4139

@@ -155,7 +153,7 @@ var trap = function (heights) {
155153
const rightHeight = heights[i]
156154
const heightGap = Math.min(leftHeight, rightHeight) - heights[poppedIndex]
157155
const width = i - indexStack.at(-1) - 1
158-
result += heightGap * width;
156+
result += heightGap * width
159157
}
160158

161159
indexStack.push(i)

0 commit comments

Comments
 (0)