Algorithm · Amazon · Medium
You are given an array strs whose elements are binary strings (each made only of the characters 0 and 1), together with two integers m and n. Choose a subset of strs so that, summed over all chosen strings, there are at most m characters equal to 0 and at most n characters equal to 1. Return the number of strings in the largest subset that satisfies both limits. When presenting your solution, begin by describing the brute-force approach, and then move on to an optimized one.…