Merge pull request #327 from LiangDazhu/patch-27

Update 0474.一和零.md
This commit is contained in:
Carl Sun
2021-06-06 11:41:06 +08:00
committed by GitHub

View File

@ -190,7 +190,18 @@ class Solution {
```
Python
```python
class Solution:
def findMaxForm(self, strs: List[str], m: int, n: int) -> int:
dp = [[0] * (n + 1) for _ in range(m + 1)]
for str in strs:
oneNum = str.count('1')
zeroNum = str.count('0')
for i in range(m, zeroNum - 1, -1):
for j in range(n, oneNum - 1, -1):
dp[i][j] = max(dp[i][j], dp[i - zeroNum][j - oneNum] + 1)
return dp[m][n]
```
Go