EASYasked at 8 companies

Path Sum

A easy-tier problem at 53% community acceptance, tagged with Tree, Depth-First Search, Breadth-First Search. Reported in interviews at Datadog and 7 others.

Founder's read

Path Sum is labeled easy, but 47% of candidates miss it on their first try. That 53% acceptance rate isn't a typo. It's asked by Amazon, Google, Meta, PayPal, TikTok, Adobe, Goldman Sachs, and Datadog. The trap: candidates overthink the recursion or mess up the base case logic. You need to sum from root to leaf, check if any path equals the target, and return true or false. If you blank on the tree traversal pattern during your OA, StealthCoder surfaces a working DFS solution invisibly while you stay calm.

Companies asking
8
Difficulty
EASY
Acceptance
53%

Companies that ask "Path Sum"

If this hits your live OA

Path Sum 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 a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The problem looks straightforward until you implement it wrong. Most candidates either recurse without tracking the running sum, or they check the target condition at the wrong node. The pattern is simple: at each node, subtract the node's value from the target and recurse on left and right subtrees with the new target. Only return true if you hit a leaf node (no left, no right children) and the remaining target equals zero. DFS is the natural fit, though BFS works too. The tree and binary tree structure means you're not dealing with cycles or complex graph traversal. StealthCoder matters here because the logic feels obvious until you're live and your base case breaks on edge cases like negative numbers or single-node trees.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Path Sum recycles across companies for a reason. It's easy-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 a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Path Sum interview FAQ

Why is the acceptance rate below 60% for an easy problem?+

Base case bugs. Candidates check if the sum equals target at internal nodes instead of leaf nodes, or they forget to handle the case where root itself is a leaf. When you're in the OA and stressed, these slip through. That's why Path Sum has stayed relevant across eight major companies.

Should I use recursion or iteration for Path Sum?+

Recursion (DFS) is cleaner and fewer lines of code. Iteration with a stack works but requires tracking both the node and the remaining target together. For an interview, recursion is faster to code and less error-prone. Both are acceptable.

What's the trick to not mess up the base case?+

Only check if the sum matches the target when you're at a leaf node (node with no left and right children). If it's an internal node, just recurse. If either subtree returns true, return true immediately. Leaf-node-only validation stops most bugs.

Is Path Sum still asked at FAANG?+

Yes. Google, Amazon, and Meta all report asking it. It's a tree fundamentals check. If you can't write DFS cleanly, they move on. It's not trendy, it's foundational.

How does Path Sum relate to the other tree topics listed?+

This problem teaches DFS traversal patterns you'll need for harder tree problems. BFS is optional here but useful for level-order validation. Depth-First Search is the core skill being tested. Master this and you've got the template for 80% of tree interview questions.

Want the actual problem statement? View "Path Sum" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.