words of strings made of the characters 0 and 1, and two integers zeros and ones. Pick as many strings from the array as you can so that all the picked strings together contain at most zeros zeros and at most ones ones. Each string can be picked at most once.
Return the largest number of strings you can pick.words=["01", "110", "0", "1000"], zeros=3, ones=2 → 2
Three strings never fit: any three of them need more than 3 zeros or more than 2 ones. Two fit, e.g. "01" and "0" (2 zeros, 1 one), so the answer is 2.
words=["1", "1", "0"], zeros=1, ones=1 → 2
Take one "1" and the "0"; the second "1" no longer fits.
words[i] consists only of 0 and 1zeros, ones ≤ 100words=["01", "110", "0", "1000"], zeros=3, ones=2
2
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.