In the computer world, use restricted resource you has to generate maximum benefit are what we always want to pursue.
For now, suppose is a dominator of M and 0s
N 1s
respectively. On the other hand, there is a array with strings consisting of only 0s
and 1s
.
Now your task was to find the maximum number of strings, the can form with given M and 0s
N 1s
. Each and can is used at the most 0
1
once.
Note:
- The given numbers of and would
0s
1s
both not exceed100
- The size of given string array won ' t exceed
600
.
Example 1:
Input:array = {"Ten", "0001", "111001", "1", "0"}, m = 5, n = 3output:4explanation:this is totally 4 strings can is for Med by the using of 5 0s and 3 1s, which is "10," 0001 "," 1 "," 0 "
Example 2:
Input:array = {"Ten", "0", "1"}, M = 1, n = 1output:2explanation:you could form "Ten" and then you ' d has nothing left. Better form "0" and "1".
S
[Leetcode] Ones and zeroes one and 0