Largest Binary-String Subset Within Bit Budgets
Problem statement
Given an array of binary strings strs and two budgets, maxOnes and maxZeroes, return the maximum number of strings you can select.
The selected strings must contain at most maxOnes ones in total and at most maxZeroes zeroes in total. Each array position may be selected at most once, including when two positions contain equal strings.
Function
largestBoundedSubset(strs: String[], maxOnes: int, maxZeroes: int) → intExamples
Example 1
strs = ["100","10","1","11","111"]maxOnes = 3maxZeroes = 0return = 2Select "1" and "11". They use exactly three ones and no zeroes.
Example 2
strs = ["10","0001","111001","1","0"]maxOnes = 3maxZeroes = 5return = 4The strings "10", "0001", "1", and "0" use three ones and five zeroes.
Example 3
strs = ["10","0","1"]maxOnes = 1maxZeroes = 1return = 2Selecting "0" and "1" uses both budgets and yields two strings.
Constraints
1 <= strs.length <= 600.1 <= strs[i].length <= 100.- Every
strs[i]contains only0and1. 0 <= maxOnes, maxZeroes <= 100.