Reported August 2026
Adobebinary tree

Count Parent Nodes With a Target Sum

Reported by candidates from Adobe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Adobe OA. Under 2s to a working solution.
Founder's read

Adobe reported this one in August 2026, and the input format is the first thing that slows people down. You get a preorder string with # for nulls, not a tree object. The job is to rebuild the structure as you read it, then count parents whose value plus both children's values hits the target. It's a binary tree problem wearing a parsing costume. If you blank on the recursive parse during the live OA, StealthCoder is the invisible safety net that reads the problem and hands you a working solution.

The problem

A binary tree is serialized in preorder as one comma-separated string preorder. Each non-null node is written as its signed integer value, and each missing child is written as #.
A parent node qualifies only when it has both a left child and a right child. Count the qualifying parent nodes whose own value plus the values of their two direct children equals target.
Return the total number of qualifying parent nodes.

Function
countTargetParents(preorder: String, target: long) → int

Examples
Example 1
preorder = "5,3,#,#,2,#,#"
target = 10
return = 1
The root has direct children 3 and 2, and 5 + 3 + 2 = 10. The leaves are not parent nodes.
Example 2
preorder = "1,2,4,#,#,5,#,#,3,#,6,#,#"
target = 11
return = 1
Node 2 has children 4 and 5, so it qualifies because 2 + 4 + 5 = 11. Node 3 has only one child and does not qualify.

Constraints
The serialization describes one valid, non-empty binary tree.
1 <= number of non-null nodes <= 2000
-10^9 <= node value <= 10^9
-3 * 10^9 <= target <= 3 * 10^9
Tokens are separated by commas and may contain surrounding spaces.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Brute force would be building a full tree, then walking it again. That works at 2000 nodes, but you don't need it. Parse tokens with a single index and a recursive function that returns the value of the node it just built, or a null marker for #. At each non-null node, call left, then right. If both come back non-null, check node + left + right == target and bump a counter. Return the node's own value to the caller. The pitfalls are real. Use 64-bit math, since three values near 10^9 plus a target up to 3 * 10^9 overflow a 32-bit int. Split on commas and trim spaces. Don't count nodes with one child. Recursion depth can hit 2000 on a skewed tree, so check your stack. StealthCoder is the hedge if the index-threading logic slips away mid-assessment.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Count Parent Nodes With a Target Sum 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Adobe's OA.

Adobe 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.

Count Parent Nodes With a Target Sum FAQ

What's the trick in Count Parent Nodes With a Target Sum?+

Don't build a tree at all. Use a recursive parse with a shared index. Each call consumes one token, recurses left then right, and returns its value or a null marker. When both children are non-null, check the sum against target and increment a counter.

How hard is this Adobe OA question really?+

Easy to medium. The logic is a simple sum check. The difficulty is parsing the preorder string with # markers correctly and avoiding overflow. If you've done any tree deserialization before, this is the same skeleton with a counter added.

Why does overflow matter here?+

Node values go up to 10^9 in magnitude, and target goes up to 3 * 10^9. Adding three node values can exceed a 32-bit int. Use long for the sum and the comparison, since the function signature already takes target as a long.

Do I need to worry about spaces in the input?+

Yes. The constraints say tokens may have surrounding spaces. Split on commas, then trim each token before checking for # or parsing the integer. Skipping the trim causes parse errors on otherwise valid input.

How do I prepare for this in 48 hours?+

Practice deserializing a preorder tree with null markers until you can write it from memory. Then add a counter and a two-child check. Also rehearse negative values and single-node trees, since a lone root has no children and returns zero.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Adobe.

OA at Adobe?
Invisible during screen share
Get it