diff --git a/docs/notes/剑指 Offer 题解 - 10~19.md b/docs/notes/剑指 Offer 题解 - 10~19.md index f913b5da..e7d1d732 100644 --- a/docs/notes/剑指 Offer 题解 - 10~19.md +++ b/docs/notes/剑指 Offer 题解 - 10~19.md @@ -98,11 +98,11 @@ public class Solution { 当 n 为 1 时,只有一种覆盖方法: -

+

当 n 为 2 时,有两种覆盖方法: -

+

要覆盖 2\*n 的大矩形,可以先覆盖 2\*1 的矩形,再覆盖 2\*(n-1) 的矩形;或者先覆盖 2\*2 的矩形,再覆盖 2\*(n-2) 的矩形。而覆盖 2\*(n-1) 和 2\*(n-2) 的矩形可以看成子问题。该问题的递推公式如下: @@ -137,6 +137,18 @@ public int RectCover(int n) { ## 解题思路 +当 n = 1 时,只有一种跳法: + +

+ +当 n = 2 时,有两种跳法: + +

+ +跳 n 阶台阶,可以先跳 1 阶台阶,再跳 n-1 阶台阶;或者先跳 2 阶台阶,再跳 n-2 阶台阶。而 n-1 和 n-2 阶台阶的跳法可以看成子问题,该问题的递推公式为: + +

+ ```java public int JumpFloor(int n) { if (n <= 2) diff --git a/docs/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png b/docs/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png new file mode 100644 index 00000000..44b12ccd Binary files /dev/null and b/docs/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png differ diff --git a/docs/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png b/docs/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png new file mode 100644 index 00000000..125a804c Binary files /dev/null and b/docs/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png differ diff --git a/docs/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png b/docs/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png new file mode 100644 index 00000000..8b25cf20 Binary files /dev/null and b/docs/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png differ diff --git a/docs/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png b/docs/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png new file mode 100644 index 00000000..6575dc98 Binary files /dev/null and b/docs/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png differ diff --git a/notes/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png b/notes/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png new file mode 100644 index 00000000..44b12ccd Binary files /dev/null and b/notes/pics/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png differ diff --git a/notes/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png b/notes/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png new file mode 100644 index 00000000..125a804c Binary files /dev/null and b/notes/pics/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png differ diff --git a/notes/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png b/notes/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png new file mode 100644 index 00000000..8b25cf20 Binary files /dev/null and b/notes/pics/f6e146f1-57ad-411b-beb3-770a142164ef.png differ diff --git a/notes/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png b/notes/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png new file mode 100644 index 00000000..6575dc98 Binary files /dev/null and b/notes/pics/fb3b8f7a-4293-4a38-aae1-62284db979a3.png differ diff --git a/notes/剑指 Offer 题解 - 10~19.md b/notes/剑指 Offer 题解 - 10~19.md index 741289f7..c1ec071a 100644 --- a/notes/剑指 Offer 题解 - 10~19.md +++ b/notes/剑指 Offer 题解 - 10~19.md @@ -98,11 +98,11 @@ public class Solution { 当 n 为 1 时,只有一种覆盖方法: -

+

当 n 为 2 时,有两种覆盖方法: -

+

要覆盖 2\*n 的大矩形,可以先覆盖 2\*1 的矩形,再覆盖 2\*(n-1) 的矩形;或者先覆盖 2\*2 的矩形,再覆盖 2\*(n-2) 的矩形。而覆盖 2\*(n-1) 和 2\*(n-2) 的矩形可以看成子问题。该问题的递推公式如下: @@ -137,6 +137,18 @@ public int RectCover(int n) { ## 解题思路 +当 n = 1 时,只有一种跳法: + +

+ +当 n = 2 时,有两种跳法: + +

+ +跳 n 阶台阶,可以先跳 1 阶台阶,再跳 n-1 阶台阶;或者先跳 2 阶台阶,再跳 n-2 阶台阶。而 n-1 和 n-2 阶台阶的跳法可以看成子问题,该问题的递推公式为: + +

+ ```java public int JumpFloor(int n) { if (n <= 2)