(String[] strs, int m, int n)
| 1 | class Solution { |
| 2 | public int findMaxForm(String[] strs, int m, int n) { |
| 3 | int[][] dp = new int[m + 1][n + 1]; |
| 4 | for (String str : strs) { |
| 5 | int zeros = (int) str.chars().filter(ch -> ch == '0').count(); |
| 6 | int ones = (int) str.chars().filter(ch -> ch == '1').count(); |
| 7 | for (int i = m; i >= zeros; i--) { |
| 8 | for (int j = n; j >= ones; j--) { |
| 9 | dp[i][j] = Math.max(dp[i][j], dp[i - zeros][j - ones] + 1); |
| 10 | } |
| 11 | } |
| 12 | } |
| 13 | return dp[m][n]; |
| 14 | } |
| 15 | } |