Subset Sum Possible
Reported by candidates from Apple's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on Apple's Subset Sum Possible is reusing an element, or brute-forcing every subset and timing out. Candidates reported this one in July 2026, and it looks simple until the constraints bite. You get an integer array and a target, and you return true if some subset sums to exactly that target, each element used at most once. The hinted pattern is depth-first search, but the version that survives is a memoized take on it. If you freeze during the live assessment, StealthCoder is the invisible hedge that reads the problem and hands you a working solution.
The problem
You are given an integer array arr and an integer target. Return true if some subset of arr has sum exactly target; otherwise return false. Each array element may be used at most once. Function isSubsetSum(arr: int[], target: int) → boolean Examples Example 1 arr = [3,34,4,12,5,2] target = 9 return = true The subset [4,5] sums to 9. The source shared the rule but did not include this exact sample. FastPrep added this small example so the behavior can be checked directly.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The core trick is the include-or-skip decision at each index. Define a function on (index, remaining). Either take arr[index] and subtract it from remaining, or skip it. Return true if remaining hits 0. Plain DFS is exponential, so memoize on (index, remaining) or flip it into a bottom-up boolean table where dp[s] means sum s is reachable. Iterate the sums backward for each number so you never use the same element twice. That backward loop is the classic pitfall. Looping forward turns it into unbounded knapsack and gives wrong answers. Check edge cases too: target 0 is true with the empty subset, and negative numbers or an empty array can break a table sized by target. Ask or assume from the statement what values appear. If you blank on the live OA, StealthCoder is the safety net that surfaces this pattern while you keep typing.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Subset Sum Possible 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Apple's OA.
Apple reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Subset Sum Possible FAQ
What's the trick for Subset Sum Possible?+
Treat each element as a choice: include it or skip it. Track the remaining target. Memoize on index and remaining, or use a boolean array of reachable sums. The key rule is each element is used once, so the order you update sums matters.
Why does my DFS time out?+
Plain recursion branches twice per element, so it's exponential in array length. Many states repeat with the same index and remaining sum. Add a memo dictionary keyed on those two values, or switch to a bottom-up table. Either one cuts it to roughly n times target.
How do I avoid reusing an element in the DP version?+
With a 1D boolean array, loop the sums from target down to the current number. Going backward means the updated value for this element can't feed into itself. Looping upward lets one element count many times, which solves a different problem.
Is this pattern still asked at Apple?+
This one was reported for Apple in July 2026, so yes, it's current. Subset sum is a standard knapsack-family question, and variants like partition equal subset sum show up often. Know the include-or-skip recursion and the 1D table cold.
How do I prepare in 48 hours?+
Write the memoized DFS from scratch, then convert it to the 1D backward-loop DP. Test with the example: [3,34,4,12,5,2] and target 9 returns true. Then test target 0, an empty array, and a target larger than the total sum. Two clean passes beat ten problems skimmed.