From 76933f018a9c2a5aa2000875e587330fda8b41a9 Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Wed, 28 Mar 2018 15:27:36 +0800 Subject: [PATCH] auto commit --- notes/Leetcode 题解.md | 32 +++++++++++------- pics/7c98e1b6-c446-4cde-8513-5c11b9f52aea.jpg | Bin 0 -> 12288 bytes 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 pics/7c98e1b6-c446-4cde-8513-5c11b9f52aea.jpg diff --git a/notes/Leetcode 题解.md b/notes/Leetcode 题解.md index 00b18a77..034533d7 100644 --- a/notes/Leetcode 题解.md +++ b/notes/Leetcode 题解.md @@ -1748,24 +1748,30 @@ public int integerBreak(int n) { ```java public int numSquares(int n) { - List squares = new ArrayList<>(); // 存储小于 n 的平方数 - int diff = 3; - while(square <= n) { - squares.add(square); - square += diff; - diff += 2; - } + List squareList = generateSquareList(n); int[] dp = new int[n + 1]; - for(int i = 1; i <= n; i++) { + for (int i = 1; i <= n; i++) { int max = Integer.MAX_VALUE; - for(int s : squares) { - if(s > i) break; - max = Math.min(max, dp[i - s] + 1); + for (int square : squareList) { + if (square > i) break; + max = Math.min(max, dp[i - square] + 1); } dp[i] = max; } return dp[n]; } + +private List generateSquareList(int n) { + List squareList = new ArrayList<>(); + int diff = 3; + int square = 1; + while (square <= n) { + squareList.add(square); + square += diff; + diff += 2; + } + return squareList; +} ``` **分割整数构成字母字符串** @@ -1798,7 +1804,9 @@ public int numDecodings(String s) { [Leetcode : 62. Unique Paths (Medium)](https://leetcode.com/problems/unique-paths/description/) -题目描述:统计从矩阵左上角到右下角的路径总数,每次只能向左和向下移动。 +题目描述:统计从矩阵左上角到右下角的路径总数,每次只能向右或者向下移动。 + +

```java public int uniquePaths(int m, int n) { diff --git a/pics/7c98e1b6-c446-4cde-8513-5c11b9f52aea.jpg b/pics/7c98e1b6-c446-4cde-8513-5c11b9f52aea.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7dcb6d1c7560610482e61b6789b8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