mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-24 10:33:34 +08:00
Update the book based on the revised second edition (#1014)
* Revised the book * Update the book with the second revised edition * Revise base on the manuscript of the first edition
This commit is contained in:
@@ -36,11 +36,11 @@ $$
|
||||
|
||||

|
||||
|
||||
由此便可推出本题的贪心策略:初始化两指针分列容器两端,每轮向内收缩短板对应的指针,直至两指针相遇。
|
||||
由此便可推出本题的贪心策略:初始化两指针,使其分列容器两端,每轮向内收缩短板对应的指针,直至两指针相遇。
|
||||
|
||||
下图展示了贪心策略的执行过程。
|
||||
|
||||
1. 初始状态下,指针 $i$ 和 $j$ 分列与数组两端。
|
||||
1. 初始状态下,指针 $i$ 和 $j$ 分列数组两端。
|
||||
2. 计算当前状态的容量 $cap[i, j]$ ,并更新最大容量。
|
||||
3. 比较板 $i$ 和 板 $j$ 的高度,并将短板向内移动一格。
|
||||
4. 循环执行第 `2.` 步和第 `3.` 步,直至 $i$ 和 $j$ 相遇时结束。
|
||||
|
||||
Reference in New Issue
Block a user