Skip to content

Commit 4c197f3

Browse files
longsizhuogithub-actions[bot]
authored andcommitted
chore(docs): sync doc metadata [skip ci]
1 parent 008dd55 commit 4c197f3

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

app/docs/CommunityShare/Leetcode/42.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
---
22
title: 42.md
3-
date: '2025/3/27-19:56'
3+
date: "2025/3/27-19:56"
44
tags:
55
- - Python
66
- - Answer
77
abbrlink: 60fe0230
8+
docId: jv8qj3ljyr2uomaehnv0l77k
89
---
910

1011
# QUESTION:
12+
1113
[42.md]()
1214

1315
# My Think:
1416

1517
滚瓜烂熟的一道题, 全部靠背诵. 但是昨天又理解了一下, 画了一个GIF图供我自己理解, 代码如下,
1618

1719
图片举例: `[0,1,0,2,1,0,1,3,2,1,2,1]`
18-
该题的核心思想其实就是木桶原理, 我们将最外面的两个柱子视作玛丽亚之墙, 这个时候我们忽略玛丽亚之墙内部的城墙, 那么最多是不是可以装`min(leftmax, rightmax)`这么高的水呢?
20+
该题的核心思想其实就是木桶原理, 我们将最外面的两个柱子视作玛丽亚之墙, 这个时候我们忽略玛丽亚之墙内部的城墙, 那么最多是不是可以装`min(leftmax, rightmax)`这么高的水呢?
1921
也就是最短的柱子的水决定了它的"高度". 但是我们想知道最多能装多少水, 还需要一个宽度. 于是这个时候我们就一根一根柱子看, 也就是说我们计算每"1"个宽度能装多少水, 然后加起来即可.
20-
我们的左指针为`left`, 右指针为`right`, 我们再维护一个左边最高和右边最高.
22+
我们的左指针为`left`, 右指针为`right`, 我们再维护一个左边最高和右边最高.
2123
当我们到达最外面的玛丽亚之墙的时候, 左最高即为`leftmax`, 右最高即为`rightmax`, 这个时候我们是无法判断可以装多少水的.
22-
一直到`leftmost`!=`rightmost`的时候, 我们就可以判断了.
24+
一直到`leftmost`!=`rightmost`的时候, 我们就可以判断了.
2325

2426
比如这一帧, 我们最多能装的是`leftmax`的水量, 即`2`, 但是因为我们这个时候左指针所在的柱子有一定高度`1`, 所以是`2-1=1`, 也就是我们能装`1`的水.
2527
如果我们比较的不是`leftmost``rightmost`, 而是`leftmax``rightmax`, 我们就无法确定说这一个柱子为什么能够兜得住水, 它之所以能兜住水,必然是<=`leftmax`
2628

27-
2829
This is a problem I’ve memorized inside out — totally muscle memory. But I revisited it yesterday and tried to actually understand it. I even made a GIF to help myself visualize what's happening. Here's the code:
2930

3031
Let's use the example: [0,1,0,2,1,0,1,3,2,1,2,1]
@@ -43,14 +44,14 @@ When our pointer reaches the end of the string (or the two walls meet), that mea
4344

4445
Take this specific frame as an example:
4546

46-
47-
At this point, the max water we can hold is leftmax = 2, but the current column has height 1, so we can trap:
47+
At this point, the max water we can hold is leftmax = 2, but the current column has height 1, so we can trap:
4848

4949
`2 - 1 = 1` unit of water.
5050

5151
If we were comparing leftmax and rightmax directly, we wouldn’t know why this particular column can hold water. The only reason it can trap water is because its height is less than or equal to leftmax.
5252

5353
# Code:
54+
5455
```python
5556
class Solution:
5657
def trap(self, height: list[int]) -> int:
@@ -67,6 +68,7 @@ class Solution:
6768
right -= 1
6869
return ans
6970
```
71+
7072
```python
7173
import matplotlib.pyplot as plt
7274
import matplotlib.animation as animation
@@ -120,4 +122,4 @@ ani = animation.FuncAnimation(fig, update, frames=frames, interval=500, repeat=F
120122

121123
from IPython.display import HTML
122124
ani.save("trapping_rain_water.gif", writer="pillow", fps=2) # 保存为 GIF
123-
```
125+
```

generated/doc-contributors.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"repo": "InvolutionHell/involutionhell",
3-
"generatedAt": "2025-12-10T03:07:16.426Z",
3+
"generatedAt": "2025-12-11T03:06:09.120Z",
44
"docsDir": "app/docs",
5-
"totalDocs": 138,
5+
"totalDocs": 139,
66
"results": [
77
{
88
"docId": "ue27z7z95yzw3lhhfj7nit1c",
@@ -2225,13 +2225,13 @@
22252225
"docId": "k4btd9x3l3xnnl4dnr64d8cq",
22262226
"path": "app/docs/CommunityShare/Leetcode/219_translated.md",
22272227
"contributorStats": {
2228-
"114939201": 1
2228+
"114939201": 2
22292229
},
22302230
"contributors": [
22312231
{
22322232
"githubId": "114939201",
2233-
"contributions": 1,
2234-
"lastContributedAt": "2025-12-10T03:00:13.000Z",
2233+
"contributions": 2,
2234+
"lastContributedAt": "2025-12-10T03:07:17.000Z",
22352235
"login": "longsizhuo",
22362236
"avatarUrl": "https://avatars.githubusercontent.com/u/114939201?v=4",
22372237
"htmlUrl": "https://github.com/longsizhuo"
@@ -2408,6 +2408,23 @@
24082408
}
24092409
]
24102410
},
2411+
{
2412+
"docId": "jv8qj3ljyr2uomaehnv0l77k",
2413+
"path": "app/docs/CommunityShare/Leetcode/42.md",
2414+
"contributorStats": {
2415+
"114939201": 1
2416+
},
2417+
"contributors": [
2418+
{
2419+
"githubId": "114939201",
2420+
"contributions": 1,
2421+
"lastContributedAt": "2025-12-11T03:00:46.000Z",
2422+
"login": "longsizhuo",
2423+
"avatarUrl": "https://avatars.githubusercontent.com/u/114939201?v=4",
2424+
"htmlUrl": "https://github.com/longsizhuo"
2425+
}
2426+
]
2427+
},
24112428
{
24122429
"docId": "mxt0ux1zpbzph4nuxz51eyg7",
24132430
"path": "app/docs/CommunityShare/Leetcode/46.全排列.md",

0 commit comments

Comments
 (0)