Amazon Coding Interview: Binary String Picker: Ones Budget
Based on questions reported for Amazon interviews
The interviewer opens
Hi, and thanks for joining. Welcome to your interview for the software engineer role at Amazon. We'll work through a coding problem together, so please think out loud as you code, and you can pause any time with the Pause button at the top right of your screen.
The problem is about choosing items from a pool under a budget, and it's up in the Problem tab now. Take your time reading it through, and let me know if you have any questions before you start.
The problem
You pick binary strings from a pool under a budget on the total number of '1' characters.
strs: a list of non-empty strings made only of '0' and '1'.m: the maximum total number of '1' characters allowed across all picked strings.
Each string may be picked at most once. Return the maximum number of strings you can pick so that the total count of '1's over the picked strings is at most m.
Example: strs = ["10","0001","111001","1","0"], m = 3 → 4
Sizes: up to 600 strings, each up to 100 characters; 0 ≤ m ≤ 100.