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

Commit f54cc50

Browse files
Update Readme.md
Avoid overwrite.
1 parent 1ae8e13 commit f54cc50

File tree

1 file changed

+2
-2
lines changed
  • Dynamic_Programming/416.Partition-Equal-Subset-Sum

1 file changed

+2
-2
lines changed

‎Dynamic_Programming/416.Partition-Equal-Subset-Sum/Readme.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
这就是01背包问题的基本思想。如果dp的空间大小合理,那么我们就可以来解决之前DFS所无法处理的复杂度。基本的模板如下:
88
```
99
for (auto x: nums) // 遍历物品
10-
for (auto s= 0 to sum/2) // 遍历容量
10+
for (auto s= sum/2 to 0) // 遍历容量
1111
if dp'[s-x] = true
1212
dp[s] = true // 如果考察x之前,已经能够凑出s-x,那么加上x这个数字就一定能凑出和为x的subset。
1313
```
1414

1515
此外还有另外一种dp的写法
1616
```
1717
for (auto x: nums) // 遍历物品
18-
for (auto s= 0 to sum/2) // 遍历容量
18+
for (auto s= sum/2 to 0) // 遍历容量
1919
if dp'[s] = true
2020
dp[s+x] = true // 如果考察x之前,已经能够凑出s,那么加上x这个数字就一定能凑出和为s+x的subset。
2121
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /