mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 04:06:51 +08:00
@ -190,7 +190,18 @@ class Solution {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Python:
|
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:
|
Go:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user