Skip to content

Commit 583cc44

Browse files
authored
Update 768.max-chunks-to-make-sorted-ii.md
1 parent 3428111 commit 583cc44

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

problems/768.max-chunks-to-make-sorted-ii.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class Solution(object):
197197

198198
比如 [2,1,3,4,4],遍历到 1 的时候会发现 1 比 2 小,因此 2, 1 需要在一块,我们可以将 2 和 1 融合,并**重新压回栈**。那么融合成 1 还是 2 呢?答案是 2,因为 2 是瓶颈,这提示我们可以用一个递增栈来完成。
199199

200+
> 为什么 2 是瓶颈?因此我们需要确保当前值一定比前面所有的值的最大值还要大。因此只需要保留最大值就好了,最大值就是瓶颈。而 1 和 2 的最大值是 2,因此 2 就是瓶颈。
201+
200202
因此本质上**栈存储的每一个元素就代表一个块,而栈里面的每一个元素的值就是块的最大值**
201203

202204
[2,1,3,4,4] 来说, stack 的变化过程大概是:

0 commit comments

Comments
 (0)