You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/1-1000/392-is-subsequence.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -243,30 +243,30 @@ end
243
243
244
244
####"Dynamic programming" is divided into five steps
245
245
246
-
1. Determine the meaning of each value of the array`dp`.
246
+
1. Determine the**meaning** of each value of the array`dp`.
247
247
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**.
250
250
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
251
251
252
252
####Detailed description of these five steps
253
253
254
-
1. Determine the meaning of each value of the array`dp`.
254
+
1. Determine the**meaning** of each value of the array`dp`.
255
255
- 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`.
256
256
- 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.
257
257
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
258
258
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
259
259
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
260
260
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
261
261
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.
263
263
- 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.
264
264
- If the original example is not good enough, you need to redesign one yourself.
265
265
- 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.
266
266
- 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.
267
267
- 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.
268
268
- 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**.
270
270
- 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.
271
271
- 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.
272
272
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
Copy file name to clipboardExpand all lines: en/1-1000/416-partition-equal-subset-sum.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -46,30 +46,30 @@ Given an integer array `nums`, return `true` if you can partition the array into
46
46
47
47
####"Dynamic programming" is divided into five steps
48
48
49
-
1. Determine the meaning of each value of the array`dp`.
49
+
1. Determine the**meaning** of each value of the array`dp`.
50
50
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**.
53
53
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
54
54
55
55
####Detailed description of these five steps
56
56
57
-
1. Determine the meaning of each value of the array`dp`.
57
+
1. Determine the**meaning** of each value of the array`dp`.
58
58
- 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`.
59
59
- 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.
60
60
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
61
61
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
62
62
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
63
63
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
64
64
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.
66
66
- 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.
67
67
- If the original example is not good enough, you need to redesign one yourself.
68
68
- 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.
69
69
- 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.
70
70
- 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.
71
71
- 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**.
73
73
- 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.
74
74
- 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.
75
75
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
375
375
376
376
####"Dynamic programming" is divided into five steps
377
377
378
-
1. Determine the meaning of each value of the array`dp`.
378
+
1. Determine the**meaning** of each value of the array`dp`.
379
379
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**.
382
382
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
383
383
384
384
####Detailed description of these five steps
385
385
386
-
1. Determine the meaning of each value of the array`dp`.
386
+
1. Determine the**meaning** of each value of the array`dp`.
387
387
- 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`.
388
388
- 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.
389
389
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
390
390
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
391
391
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
392
392
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
393
393
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.
395
395
- 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.
396
396
- If the original example is not good enough, you need to redesign one yourself.
397
397
- 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.
398
398
- 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.
399
399
- 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.
400
400
- 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**.
402
402
- 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.
403
403
- 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.
404
404
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
Copy file name to clipboardExpand all lines: en/1-1000/474-ones-and-zeroes.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -57,30 +57,30 @@ This question is difficult. It is recommended to complete a simple question of t
57
57
58
58
####"Dynamic programming" is divided into five steps
59
59
60
-
1. Determine the meaning of each value of the array`dp`.
60
+
1. Determine the**meaning** of each value of the array`dp`.
61
61
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**.
64
64
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
65
65
66
66
####Detailed description of these five steps
67
67
68
-
1. Determine the meaning of each value of the array`dp`.
68
+
1. Determine the**meaning** of each value of the array`dp`.
69
69
- 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`.
70
70
- 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.
71
71
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
72
72
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
73
73
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
74
74
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
75
75
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.
77
77
- 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.
78
78
- If the original example is not good enough, you need to redesign one yourself.
79
79
- 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.
80
80
- 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.
81
81
- 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.
82
82
- 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**.
84
84
- 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.
85
85
- 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.
86
86
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
Copy file name to clipboardExpand all lines: en/1-1000/494-target-sum.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -52,30 +52,30 @@ This problem is quite difficult if you have not solved similar problems before.
52
52
53
53
####"Dynamic programming" is divided into five steps
54
54
55
-
1. Determine the meaning of each value of the array`dp`.
55
+
1. Determine the**meaning** of each value of the array`dp`.
56
56
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**.
59
59
5. Write a program and print the`dp` array. If it is not as expected, adjust it.
60
60
61
61
####Detailed description of these five steps
62
62
63
-
1. Determine the meaning of each value of the array`dp`.
63
+
1. Determine the**meaning** of each value of the array`dp`.
64
64
- 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`.
65
65
- 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.
66
66
- Try to save more information in the design. Repeated information only needs to be saved once in a`dp[i]`.
67
67
- Use simplified meanings. If the problem can be solved with`boolean value`, don't use`numeric value`.
68
68
2. Initialize the value of the array`dp`. The value of`dp` involves two levels:
69
69
1. The length of`dp`. Usually:`condition array length plus 1` or`condition array length`.
70
70
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.
72
72
- 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.
73
73
- If the original example is not good enough, you need to redesign one yourself.
74
74
- 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.
75
75
- 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.
76
76
- 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.
77
77
- 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**.
79
79
- 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.
80
80
- 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.
81
81
5. Write a program and print the`dp` array. If it is not as expected, adjust it.