classSolution(object):deffindMaxForm(self, strs, m, n):"""
:type strs: List[str]
:type m: int
:type n: int
:rtype: int
"""
dp=[[0]*(n+1)for i inrange(m+1)]for onestr in strs:
one_num = onestr.count('1')
zero_num =len(onestr)-one_num
for i inrange(m, zero_num-1,-1):for j inrange(n, one_num-1,-1):
dp[i][j]=max(dp[i][j], dp[i-zero_num][j-one_num]+1)return dp[m][n]