Maximum Number of Integers to Choose From a Range I
A medium-tier problem at 68% community acceptance, tagged with Array, Hash Table, Binary Search. Reported in interviews at PayPal and 0 others.
Maximum Number of Integers to Choose From a Range I is a medium-difficulty greedy problem that tests whether you can spot the optimal selection strategy under constraints. PayPal has asked it. The acceptance rate sits around 68%, which means most candidates who see it can solve it, but you need to recognize that the straightforward approach of picking every available number won't work. The trick is understanding when to skip an option to unlock more choices downstream. If this problem hits your live assessment and you blank on the greedy ordering, StealthCoder solves it in seconds invisible to the proctor.
Companies that ask "Maximum Number of Integers to Choose From a Range I"
Maximum Number of Integers to Choose From a Range I is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe problem asks you to select the maximum count of integers from a range while avoiding a forbidden set. The naive instinct is to iterate through the range and grab everything not in the forbidden set. That fails because you have a constraint (usually a sum limit) that forces tradeoffs. The winning insight is greedy: sort your candidates and pick in order, checking whether each addition exceeds your budget before committing. Hash tables handle forbidden-set lookups in constant time. Some candidates waste time on binary search when a hash lookup is enough. The pitfall is not realizing that greedy works here because there's no reason to ever pick a larger number before smaller ones when you're trying to maximize count. StealthCoder is the hedge if you arrive at the assessment unsure whether greedy is safe or if you need dynamic programming.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum Number of Integers to Choose From a Range I recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Number of Integers to Choose From a Range I interview FAQ
Is this really a medium problem?+
The 68% acceptance rate suggests most people who attempt it pass. But that's often because OA candidates have already drilled greedy patterns. First time seeing the constraint-selection setup, it's harder. The trap is overthinking into DP when greedy is correct and much simpler.
Why does PayPal ask this?+
It filters for candidates who can spot a greedy solution under pressure without overcomplicating. PayPal interviews tend to value practical optimization over textbook complexity. This problem rewards clarity of thought, not arcane algorithm knowledge.
What's the actual trick?+
Sort the candidates and pick smallest first. Use a hash table for O(1) forbidden-set lookup. Iterate in order, checking your constraint before each addition. If you pick larger numbers before smaller, you'll leave gaps in your total count. Greedy is optimal because count only grows if you minimize the sum of each integer you choose.
Does this relate to other greedy problems I should know?+
Yes. It's structurally similar to interval scheduling and activity selection where you sort and pick greedily. The Array and Sorting topics confirm it. Once you see the pattern, many greedy selection problems click. Hash Table is just the implementation detail for checking forbidden values fast.
What if I freeze on this during the OA?+
If you can't recall whether greedy works or if you're stuck on the constraint logic, that's exactly when StealthCoder runs invisibly and surfaces a working solution. You get the code, understand it in 30 seconds, and move on. No proctor sees it.
Want the actual problem statement? View "Maximum Number of Integers to Choose From a Range I" on LeetCode →