auto commit
This commit is contained in:
@ -46,7 +46,9 @@
|
||||
|
||||
## 1. 爬楼梯
|
||||
|
||||
[70. Climbing Stairs (Easy)](https://leetcode.com/problems/climbing-stairs/description/)
|
||||
70\. Climbing Stairs (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/climbing-stairs/description/) / [力扣](https://leetcode-cn.com/problems/climbing-stairs/description/)
|
||||
|
||||
题目描述:有 N 阶楼梯,每次可以上一阶或者两阶,求有多少种上楼梯的方法。
|
||||
|
||||
@ -77,7 +79,9 @@ public int climbStairs(int n) {
|
||||
|
||||
## 2. 强盗抢劫
|
||||
|
||||
[198. House Robber (Easy)](https://leetcode.com/problems/house-robber/description/)
|
||||
198\. House Robber (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/house-robber/description/) / [力扣](https://leetcode-cn.com/problems/house-robber/description/)
|
||||
|
||||
题目描述:抢劫一排住户,但是不能抢邻近的住户,求最大抢劫量。
|
||||
|
||||
@ -103,7 +107,9 @@ public int rob(int[] nums) {
|
||||
|
||||
## 3. 强盗在环形街区抢劫
|
||||
|
||||
[213. House Robber II (Medium)](https://leetcode.com/problems/house-robber-ii/description/)
|
||||
213\. House Robber II (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/house-robber-ii/description/) / [力扣](https://leetcode-cn.com/problems/house-robber-ii/description/)
|
||||
|
||||
```java
|
||||
public int rob(int[] nums) {
|
||||
@ -159,7 +165,9 @@ private int rob(int[] nums, int first, int last) {
|
||||
|
||||
## 1. 矩阵的最小路径和
|
||||
|
||||
[64. Minimum Path Sum (Medium)](https://leetcode.com/problems/minimum-path-sum/description/)
|
||||
64\. Minimum Path Sum (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/minimum-path-sum/description/) / [力扣](https://leetcode-cn.com/problems/minimum-path-sum/description/)
|
||||
|
||||
```html
|
||||
[[1,3,1],
|
||||
@ -195,7 +203,9 @@ public int minPathSum(int[][] grid) {
|
||||
|
||||
## 2. 矩阵的总路径数
|
||||
|
||||
[62. Unique Paths (Medium)](https://leetcode.com/problems/unique-paths/description/)
|
||||
62\. Unique Paths (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/unique-paths/description/) / [力扣](https://leetcode-cn.com/problems/unique-paths/description/)
|
||||
|
||||
题目描述:统计从矩阵左上角到右下角的路径总数,每次只能向右或者向下移动。
|
||||
|
||||
@ -232,7 +242,9 @@ public int uniquePaths(int m, int n) {
|
||||
|
||||
## 1. 数组区间和
|
||||
|
||||
[303. Range Sum Query - Immutable (Easy)](https://leetcode.com/problems/range-sum-query-immutable/description/)
|
||||
303\. Range Sum Query - Immutable (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/range-sum-query-immutable/description/) / [力扣](https://leetcode-cn.com/problems/range-sum-query-immutable/description/)
|
||||
|
||||
```html
|
||||
Given nums = [-2, 0, 3, -5, 2, -1]
|
||||
@ -264,7 +276,9 @@ class NumArray {
|
||||
|
||||
## 2. 数组中等差递增子区间的个数
|
||||
|
||||
[413. Arithmetic Slices (Medium)](https://leetcode.com/problems/arithmetic-slices/description/)
|
||||
413\. Arithmetic Slices (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/arithmetic-slices/description/) / [力扣](https://leetcode-cn.com/problems/arithmetic-slices/description/)
|
||||
|
||||
```html
|
||||
A = [0, 1, 2, 3, 4]
|
||||
@ -323,7 +337,9 @@ public int numberOfArithmeticSlices(int[] A) {
|
||||
|
||||
## 1. 分割整数的最大乘积
|
||||
|
||||
[343. Integer Break (Medim)](https://leetcode.com/problems/integer-break/description/)
|
||||
343\. Integer Break (Medim)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/integer-break/description/) / [力扣](https://leetcode-cn.com/problems/integer-break/description/)
|
||||
|
||||
题目描述:For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 + 3 + 4).
|
||||
|
||||
@ -342,7 +358,9 @@ public int integerBreak(int n) {
|
||||
|
||||
## 2. 按平方数来分割整数
|
||||
|
||||
[279. Perfect Squares(Medium)](https://leetcode.com/problems/perfect-squares/description/)
|
||||
279\. Perfect Squares(Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/perfect-squares/description/) / [力扣](https://leetcode-cn.com/problems/perfect-squares/description/)
|
||||
|
||||
题目描述:For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9.
|
||||
|
||||
@ -378,7 +396,9 @@ private List<Integer> generateSquareList(int n) {
|
||||
|
||||
## 3. 分割整数构成字母字符串
|
||||
|
||||
[91. Decode Ways (Medium)](https://leetcode.com/problems/decode-ways/description/)
|
||||
91\. Decode Ways (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/decode-ways/description/) / [力扣](https://leetcode-cn.com/problems/decode-ways/description/)
|
||||
|
||||
题目描述:Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12).
|
||||
|
||||
@ -426,7 +446,9 @@ public int numDecodings(String s) {
|
||||
|
||||
## 1. 最长递增子序列
|
||||
|
||||
[300. Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/longest-increasing-subsequence/description/)
|
||||
300\. Longest Increasing Subsequence (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/longest-increasing-subsequence/description/) / [力扣](https://leetcode-cn.com/problems/longest-increasing-subsequence/description/)
|
||||
|
||||
```java
|
||||
public int lengthOfLIS(int[] nums) {
|
||||
@ -508,7 +530,9 @@ private int binarySearch(int[] tails, int len, int key) {
|
||||
|
||||
## 2. 一组整数对能够构成的最长链
|
||||
|
||||
[646. Maximum Length of Pair Chain (Medium)](https://leetcode.com/problems/maximum-length-of-pair-chain/description/)
|
||||
646\. Maximum Length of Pair Chain (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/maximum-length-of-pair-chain/description/) / [力扣](https://leetcode-cn.com/problems/maximum-length-of-pair-chain/description/)
|
||||
|
||||
```html
|
||||
Input: [[1,2], [2,3], [3,4]]
|
||||
@ -540,7 +564,9 @@ public int findLongestChain(int[][] pairs) {
|
||||
|
||||
## 3. 最长摆动子序列
|
||||
|
||||
[376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence/description/)
|
||||
376\. Wiggle Subsequence (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/wiggle-subsequence/description/) / [力扣](https://leetcode-cn.com/problems/wiggle-subsequence/description/)
|
||||
|
||||
```html
|
||||
Input: [1,7,4,9,2,5]
|
||||
@ -697,7 +723,9 @@ public int knapsack(int W, int N, int[] weights, int[] values) {
|
||||
|
||||
## 1. 划分数组为和相等的两部分
|
||||
|
||||
[416. Partition Equal Subset Sum (Medium)](https://leetcode.com/problems/partition-equal-subset-sum/description/)
|
||||
416\. Partition Equal Subset Sum (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/partition-equal-subset-sum/description/) / [力扣](https://leetcode-cn.com/problems/partition-equal-subset-sum/description/)
|
||||
|
||||
```html
|
||||
Input: [1, 5, 11, 5]
|
||||
@ -737,7 +765,9 @@ private int computeArraySum(int[] nums) {
|
||||
|
||||
## 2. 改变一组数的正负号使得它们的和为一给定数
|
||||
|
||||
[494. Target Sum (Medium)](https://leetcode.com/problems/target-sum/description/)
|
||||
494\. Target Sum (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/target-sum/description/) / [力扣](https://leetcode-cn.com/problems/target-sum/description/)
|
||||
|
||||
```html
|
||||
Input: nums is [1, 1, 1, 1, 1], S is 3.
|
||||
@ -809,7 +839,9 @@ private int findTargetSumWays(int[] nums, int start, int S) {
|
||||
|
||||
## 3. 01 字符构成最多的字符串
|
||||
|
||||
[474. Ones and Zeroes (Medium)](https://leetcode.com/problems/ones-and-zeroes/description/)
|
||||
474\. Ones and Zeroes (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/ones-and-zeroes/description/) / [力扣](https://leetcode-cn.com/problems/ones-and-zeroes/description/)
|
||||
|
||||
```html
|
||||
Input: Array = {"10", "0001", "111001", "1", "0"}, m = 5, n = 3
|
||||
@ -847,7 +879,9 @@ public int findMaxForm(String[] strs, int m, int n) {
|
||||
|
||||
## 4. 找零钱的最少硬币数
|
||||
|
||||
[322. Coin Change (Medium)](https://leetcode.com/problems/coin-change/description/)
|
||||
322\. Coin Change (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/coin-change/description/) / [力扣](https://leetcode-cn.com/problems/coin-change/description/)
|
||||
|
||||
```html
|
||||
Example 1:
|
||||
@ -888,7 +922,9 @@ public int coinChange(int[] coins, int amount) {
|
||||
|
||||
## 5. 找零钱的硬币数组合
|
||||
|
||||
[518\. Coin Change 2 (Medium)](https://leetcode.com/problems/coin-change-2/description/)
|
||||
518\. Coin Change 2 (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/coin-change-2/description/) / [力扣](https://leetcode-cn.com/problems/coin-change-2/description/)
|
||||
|
||||
```text-html-basic
|
||||
Input: amount = 5, coins = [1, 2, 5]
|
||||
@ -920,7 +956,9 @@ public int change(int amount, int[] coins) {
|
||||
|
||||
## 6. 字符串按单词列表分割
|
||||
|
||||
[139. Word Break (Medium)](https://leetcode.com/problems/word-break/description/)
|
||||
139\. Word Break (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/word-break/description/) / [力扣](https://leetcode-cn.com/problems/word-break/description/)
|
||||
|
||||
```html
|
||||
s = "leetcode",
|
||||
@ -957,7 +995,9 @@ public boolean wordBreak(String s, List<String> wordDict) {
|
||||
|
||||
## 7. 组合总和
|
||||
|
||||
[377. Combination Sum IV (Medium)](https://leetcode.com/problems/combination-sum-iv/description/)
|
||||
377\. Combination Sum IV (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/combination-sum-iv/description/) / [力扣](https://leetcode-cn.com/problems/combination-sum-iv/description/)
|
||||
|
||||
```html
|
||||
nums = [1, 2, 3]
|
||||
@ -1000,7 +1040,9 @@ public int combinationSum4(int[] nums, int target) {
|
||||
|
||||
## 1. 需要冷却期的股票交易
|
||||
|
||||
[309. Best Time to Buy and Sell Stock with Cooldown(Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/)
|
||||
309\. Best Time to Buy and Sell Stock with Cooldown(Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/) / [力扣](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/)
|
||||
|
||||
题目描述:交易之后需要有一天的冷却时间。
|
||||
|
||||
@ -1030,7 +1072,9 @@ public int maxProfit(int[] prices) {
|
||||
|
||||
## 2. 需要交易费用的股票交易
|
||||
|
||||
[714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/)
|
||||
714\. Best Time to Buy and Sell Stock with Transaction Fee (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/) / [力扣](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/)
|
||||
|
||||
```html
|
||||
Input: prices = [1, 3, 2, 8, 4, 9], fee = 2
|
||||
@ -1069,7 +1113,9 @@ public int maxProfit(int[] prices, int fee) {
|
||||
|
||||
## 3. 只能进行两次的股票交易
|
||||
|
||||
[123. Best Time to Buy and Sell Stock III (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/description/)
|
||||
123\. Best Time to Buy and Sell Stock III (Hard)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/description/) / [力扣](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/description/)
|
||||
|
||||
```java
|
||||
public int maxProfit(int[] prices) {
|
||||
@ -1095,7 +1141,9 @@ public int maxProfit(int[] prices) {
|
||||
|
||||
## 4. 只能进行 k 次的股票交易
|
||||
|
||||
[188. Best Time to Buy and Sell Stock IV (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/description/)
|
||||
188\. Best Time to Buy and Sell Stock IV (Hard)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/description/) / [力扣](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iv/description/)
|
||||
|
||||
```java
|
||||
public int maxProfit(int k, int[] prices) {
|
||||
@ -1125,7 +1173,9 @@ public int maxProfit(int k, int[] prices) {
|
||||
|
||||
## 1. 删除两个字符串的字符使它们相等
|
||||
|
||||
[583. Delete Operation for Two Strings (Medium)](https://leetcode.com/problems/delete-operation-for-two-strings/description/)
|
||||
583\. Delete Operation for Two Strings (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/delete-operation-for-two-strings/description/) / [力扣](https://leetcode-cn.com/problems/delete-operation-for-two-strings/description/)
|
||||
|
||||
```html
|
||||
Input: "sea", "eat"
|
||||
@ -1154,7 +1204,9 @@ public int minDistance(String word1, String word2) {
|
||||
|
||||
## 2. 编辑距离
|
||||
|
||||
[72. Edit Distance (Hard)](https://leetcode.com/problems/edit-distance/description/)
|
||||
72\. Edit Distance (Hard)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/edit-distance/description/) / [力扣](https://leetcode-cn.com/problems/edit-distance/description/)
|
||||
|
||||
```html
|
||||
Example 1:
|
||||
@ -1207,7 +1259,9 @@ public int minDistance(String word1, String word2) {
|
||||
|
||||
## 3. 复制粘贴字符
|
||||
|
||||
[650. 2 Keys Keyboard (Medium)](https://leetcode.com/problems/2-keys-keyboard/description/)
|
||||
650\. 2 Keys Keyboard (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/2-keys-keyboard/description/) / [力扣](https://leetcode-cn.com/problems/2-keys-keyboard/description/)
|
||||
|
||||
题目描述:最开始只有一个字符 A,问需要多少次操作能够得到 n 个字符 A,每次操作可以复制当前所有的字符,或者粘贴。
|
||||
|
||||
|
Reference in New Issue
Block a user