Ones and Zeroes Problem

Ones and Zeroes Problem — ExecCode Medium DSA Practice

Solve the Ones and Zeroes problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given an array of binary strings strs and two integers m and n. Return the size of the largest subset of strs such that there are at most m 0s and n 1s in the subset.

Examples

Input strs = ["10", "0", "1"], m = 1, n = 1; Output 2. Input strs = ["10", "0001", "111001", "1", "0"], m = 5, n = 3; Output 4. Input strs = ["10", "0", "1"], m = 1, n = 0; Output 1

Constraints

1 ≤ strs.length ≤ 600 1 ≤ strs[i].length ≤ 100 1 ≤ m, n ≤ 100

Practice Ones and Zeroes free on ExecCode. Browse DSA problems, topic map, and placement guides.