Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb967249

Browse files
committed
Update all solutions' changes in 2025-04-25.
1 parent7af79d8 commitb967249

File tree

52 files changed

+688
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+688
-577
lines changed

‎en/1-1000/392-is-subsequence.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,30 +243,30 @@ end
243243

244244
####"Dynamic programming" is divided into five steps
245245

246-
1. Determine the meaning of each value of the array`dp`.
246+
1. Determine the**meaning** of each value of the array`dp`.
247247
2. Initialize the value of the array`dp`.
248-
3. Fill in the`dp` grid data"in order" according to an example.
249-
4. Based on the`dp` grid data, derive the"recursive formula".
248+
3. Fill in the`dp` grid data**in order** according to an example.
249+
4. Based on the`dp` grid data, derive the**recursive formula**.
250250
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
251251

252252
####Detailed description of these five steps
253253

254-
1. Determine the meaning of each value of the array`dp`.
254+
1. Determine the**meaning** of each value of the array`dp`.
255255
- First determine whether`dp` is a one-dimensional array or a two-dimensional array. A`one-dimensional rolling array` means that the values ​​of the array are overwritten at each iteration. Most of the time, using`one-dimensional rolling array` instead of`two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use`two-dimensional array`.
256256
- Try to use the meaning of the`return value` required by the problem as the meaning of`dp[i]` (one-dimensional) or`dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
257257
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
258258
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
259259
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
260260
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
261261
2. The value of`dp[i]` or`dp[i][j]`.`dp[0]` or`dp[0][0]` sometimes requires special treatment.
262-
3. Fill in the`dp` grid data"in order" according to an example.
262+
3. Fill in the`dp` grid data**in order** according to an example.
263263
- The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
264264
- If the original example is not good enough, you need to redesign one yourself.
265265
- According to the example, fill in the`dp` grid data "in order", which is very important because it determines the traversal order of the code.
266266
- Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
267267
- When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the`dp` grid data "in order". This order is also the order in which the program processes.
268268
- In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
269-
4. Based on the`dp` grid data, derive the"recursive formula".
269+
4. Based on the`dp` grid data, derive the**recursive formula**.
270270
- There are three special positions to pay attention to:`dp[i - 1][j - 1]`,`dp[i - 1][j]` and`dp[i][j - 1]`, the current`dp[i][j]` often depends on them.
271271
- When operating "two swappable arrays", due to symmetry, we may need to use`dp[i - 1][j]` and`dp[i][j - 1]` at the same time.
272272
5. Write a program and print the`dp` array. If it is not as expected, adjust it.

‎en/1-1000/416-partition-equal-subset-sum.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,30 @@ Given an integer array `nums`, return `true` if you can partition the array into
4646

4747
####"Dynamic programming" is divided into five steps
4848

49-
1. Determine the meaning of each value of the array`dp`.
49+
1. Determine the**meaning** of each value of the array`dp`.
5050
2. Initialize the value of the array`dp`.
51-
3. Fill in the`dp` grid data"in order" according to an example.
52-
4. Based on the`dp` grid data, derive the"recursive formula".
51+
3. Fill in the`dp` grid data**in order** according to an example.
52+
4. Based on the`dp` grid data, derive the**recursive formula**.
5353
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
5454

5555
####Detailed description of these five steps
5656

57-
1. Determine the meaning of each value of the array`dp`.
57+
1. Determine the**meaning** of each value of the array`dp`.
5858
- First determine whether`dp` is a one-dimensional array or a two-dimensional array. A`one-dimensional rolling array` means that the values ​​of the array are overwritten at each iteration. Most of the time, using`one-dimensional rolling array` instead of`two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use`two-dimensional array`.
5959
- Try to use the meaning of the`return value` required by the problem as the meaning of`dp[i]` (one-dimensional) or`dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
6060
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
6161
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
6262
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
6363
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
6464
2. The value of`dp[i]` or`dp[i][j]`.`dp[0]` or`dp[0][0]` sometimes requires special treatment.
65-
3. Fill in the`dp` grid data"in order" according to an example.
65+
3. Fill in the`dp` grid data**in order** according to an example.
6666
- The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
6767
- If the original example is not good enough, you need to redesign one yourself.
6868
- According to the example, fill in the`dp` grid data "in order", which is very important because it determines the traversal order of the code.
6969
- Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
7070
- When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the`dp` grid data "in order". This order is also the order in which the program processes.
7171
- In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
72-
4. Based on the`dp` grid data, derive the"recursive formula".
72+
4. Based on the`dp` grid data, derive the**recursive formula**.
7373
- There are three special positions to pay attention to:`dp[i - 1][j - 1]`,`dp[i - 1][j]` and`dp[i][j - 1]`, the current`dp[i][j]` often depends on them.
7474
- When operating "two swappable arrays", due to symmetry, we may need to use`dp[i - 1][j]` and`dp[i][j - 1]` at the same time.
7575
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
@@ -375,30 +375,30 @@ During the interview, you need to remember it. Is there any way to not worry abo
375375

376376
####"Dynamic programming" is divided into five steps
377377

378-
1. Determine the meaning of each value of the array`dp`.
378+
1. Determine the**meaning** of each value of the array`dp`.
379379
2. Initialize the value of the array`dp`.
380-
3. Fill in the`dp` grid data"in order" according to an example.
381-
4. Based on the`dp` grid data, derive the"recursive formula".
380+
3. Fill in the`dp` grid data**in order** according to an example.
381+
4. Based on the`dp` grid data, derive the**recursive formula**.
382382
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
383383

384384
####Detailed description of these five steps
385385

386-
1. Determine the meaning of each value of the array`dp`.
386+
1. Determine the**meaning** of each value of the array`dp`.
387387
- First determine whether`dp` is a one-dimensional array or a two-dimensional array. A`one-dimensional rolling array` means that the values ​​of the array are overwritten at each iteration. Most of the time, using`one-dimensional rolling array` instead of`two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use`two-dimensional array`.
388388
- Try to use the meaning of the`return value` required by the problem as the meaning of`dp[i]` (one-dimensional) or`dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
389389
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
390390
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
391391
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
392392
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
393393
2. The value of`dp[i]` or`dp[i][j]`.`dp[0]` or`dp[0][0]` sometimes requires special treatment.
394-
3. Fill in the`dp` grid data"in order" according to an example.
394+
3. Fill in the`dp` grid data**in order** according to an example.
395395
- The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
396396
- If the original example is not good enough, you need to redesign one yourself.
397397
- According to the example, fill in the`dp` grid data "in order", which is very important because it determines the traversal order of the code.
398398
- Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
399399
- When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the`dp` grid data "in order". This order is also the order in which the program processes.
400400
- In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
401-
4. Based on the`dp` grid data, derive the"recursive formula".
401+
4. Based on the`dp` grid data, derive the**recursive formula**.
402402
- There are three special positions to pay attention to:`dp[i - 1][j - 1]`,`dp[i - 1][j]` and`dp[i][j - 1]`, the current`dp[i][j]` often depends on them.
403403
- When operating "two swappable arrays", due to symmetry, we may need to use`dp[i - 1][j]` and`dp[i][j - 1]` at the same time.
404404
5. Write a program and print the`dp` array. If it is not as expected, adjust it.

‎en/1-1000/474-ones-and-zeroes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,30 @@ This question is difficult. It is recommended to complete a simple question of t
5757

5858
####"Dynamic programming" is divided into five steps
5959

60-
1. Determine the meaning of each value of the array`dp`.
60+
1. Determine the**meaning** of each value of the array`dp`.
6161
2. Initialize the value of the array`dp`.
62-
3. Fill in the`dp` grid data"in order" according to an example.
63-
4. Based on the`dp` grid data, derive the"recursive formula".
62+
3. Fill in the`dp` grid data**in order** according to an example.
63+
4. Based on the`dp` grid data, derive the**recursive formula**.
6464
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
6565

6666
####Detailed description of these five steps
6767

68-
1. Determine the meaning of each value of the array`dp`.
68+
1. Determine the**meaning** of each value of the array`dp`.
6969
- First determine whether`dp` is a one-dimensional array or a two-dimensional array. A`one-dimensional rolling array` means that the values ​​of the array are overwritten at each iteration. Most of the time, using`one-dimensional rolling array` instead of`two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use`two-dimensional array`.
7070
- Try to use the meaning of the`return value` required by the problem as the meaning of`dp[i]` (one-dimensional) or`dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
7171
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
7272
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
7373
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
7474
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
7575
2. The value of`dp[i]` or`dp[i][j]`.`dp[0]` or`dp[0][0]` sometimes requires special treatment.
76-
3. Fill in the`dp` grid data"in order" according to an example.
76+
3. Fill in the`dp` grid data**in order** according to an example.
7777
- The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
7878
- If the original example is not good enough, you need to redesign one yourself.
7979
- According to the example, fill in the`dp` grid data "in order", which is very important because it determines the traversal order of the code.
8080
- Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
8181
- When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the`dp` grid data "in order". This order is also the order in which the program processes.
8282
- In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
83-
4. Based on the`dp` grid data, derive the"recursive formula".
83+
4. Based on the`dp` grid data, derive the**recursive formula**.
8484
- There are three special positions to pay attention to:`dp[i - 1][j - 1]`,`dp[i - 1][j]` and`dp[i][j - 1]`, the current`dp[i][j]` often depends on them.
8585
- When operating "two swappable arrays", due to symmetry, we may need to use`dp[i - 1][j]` and`dp[i][j - 1]` at the same time.
8686
5. Write a program and print the`dp` array. If it is not as expected, adjust it.

‎en/1-1000/494-target-sum.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,30 @@ This problem is quite difficult if you have not solved similar problems before.
5252

5353
####"Dynamic programming" is divided into five steps
5454

55-
1. Determine the meaning of each value of the array`dp`.
55+
1. Determine the**meaning** of each value of the array`dp`.
5656
2. Initialize the value of the array`dp`.
57-
3. Fill in the`dp` grid data"in order" according to an example.
58-
4. Based on the`dp` grid data, derive the"recursive formula".
57+
3. Fill in the`dp` grid data**in order** according to an example.
58+
4. Based on the`dp` grid data, derive the**recursive formula**.
5959
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
6060

6161
####Detailed description of these five steps
6262

63-
1. Determine the meaning of each value of the array`dp`.
63+
1. Determine the**meaning** of each value of the array`dp`.
6464
- First determine whether`dp` is a one-dimensional array or a two-dimensional array. A`one-dimensional rolling array` means that the values ​​of the array are overwritten at each iteration. Most of the time, using`one-dimensional rolling array` instead of`two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use`two-dimensional array`.
6565
- Try to use the meaning of the`return value` required by the problem as the meaning of`dp[i]` (one-dimensional) or`dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
6666
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
6767
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
6868
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
6969
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
7070
2. The value of`dp[i]` or`dp[i][j]`.`dp[0]` or`dp[0][0]` sometimes requires special treatment.
71-
3. Fill in the`dp` grid data"in order" according to an example.
71+
3. Fill in the`dp` grid data**in order** according to an example.
7272
- The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
7373
- If the original example is not good enough, you need to redesign one yourself.
7474
- According to the example, fill in the`dp` grid data "in order", which is very important because it determines the traversal order of the code.
7575
- Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
7676
- When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the`dp` grid data "in order". This order is also the order in which the program processes.
7777
- In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
78-
4. Based on the`dp` grid data, derive the"recursive formula".
78+
4. Based on the`dp` grid data, derive the**recursive formula**.
7979
- There are three special positions to pay attention to:`dp[i - 1][j - 1]`,`dp[i - 1][j]` and`dp[i][j - 1]`, the current`dp[i][j]` often depends on them.
8080
- When operating "two swappable arrays", due to symmetry, we may need to use`dp[i - 1][j]` and`dp[i][j - 1]` at the same time.
8181
5. Write a program and print the`dp` array. If it is not as expected, adjust it.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp