Distribute Integers Between Arrays
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
ZipRecruiter asked this in February and candidates report it landed without much warning. You're distributing integers across two arrays with constraints on which values go where. The trick isn't obvious from the title alone, which is why people blank. The real work is figuring out the distribution rule and then handling edge cases where no valid split exists. This is a constraint-satisfaction problem disguised as a simple distribution task. If you freeze during the live OA, StealthCoder runs invisibly and reads the exact constraint off your screen, then feeds you the pattern in real time.
Pattern and pitfall
The problem gives you a set of integers and asks you to split them into two arrays subject to specific rules about value ranges or sums. The naive approach is greedy: iterate through values and assign each one based on whether it fits the current constraints. That fails because early commits block later valid assignments. The actual pattern is either backtracking to explore all valid distributions, or a greedy approach that respects a specific ordering of integers. Many candidates try to optimize too early and miss that the constraint set is small enough to brute force. The common pitfall is assuming one greedy order works when the problem requires you to try multiple orderings or backtrack. During the live OA, if the constraint language is ambiguous, StealthCoder helps you parse it correctly by showing you what similar problems on this platform typically mean.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Distribute Integers Between Arrays cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as partition equal subset sum. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Distribute Integers Between Arrays FAQ
Is this a backtracking problem or greedy?+
Both work depending on the exact constraints given. If integers are small or the constraint set is tight, backtracking explores all valid partitions and returns one or all solutions. If the constraint is simple (like sum balance), greedy sorting works. Read the problem statement carefully to see whether you need to find one solution or all solutions.
What's the trick ZipRecruiter expects?+
The trick is recognizing that order matters. Many candidates iterate through integers in input order and fail. The solution often requires sorting by a key that respects the constraints, or using backtracking to undo bad choices. If you sort wrong, your greedy assignment fails silently.
How do I handle the case where no valid distribution exists?+
Check your base case. If you've assigned all integers and both arrays satisfy their constraints, return true. If you exhaust all orderings without success, return false or an empty result. Don't assume a solution always exists.
Should I use recursion or iteration?+
Recursion is cleaner for backtracking. You try assigning the next integer to array A, recurse, backtrack if it fails, then try array B. Iteration works too but requires explicit state management. ZipRecruiter doesn't usually penalize either approach if both are correct.
What's the complexity I should aim for?+
Backtracking is O(2^n) worst case where n is the number of integers. Greedy with sorting is O(n log n). If n is under 20, backtracking passes. If n is larger, you need a greedy insight or a smarter constraint. Ask yourself if pruning or memoization cuts the search space.