FastPrepCheck Whether a Tree Is a Sum Tree
Problems/Check Whether a Tree Is a Sum Tree

Check Whether a Tree Is a Sum Tree

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You check whether every non-leaf node of a binary tree equals the total of the values below it. The source is a May 2022 post by a C++ engineer selected for an Adobe CS role in Noida. In its first round the task is named. The author has to weigh two ways of solving it against each other and write both: a bottom-up pass from the leaves and a top-down pass from the root. C++ memory topics and a design task filled the rest of that round, and are not part of this problem. The post gives no definition, limits or examples.

We use the common definition of a sum tree. This is our reading, since the post gives none. Each node with a child equals the sum of everything in its two subtrees, and leaves need no check. We chose these limits: 1 to 500 nodes with 32-bit values, so the sums need 64-bit arithmetic. We wrote new examples. The tests check only the answer, not which version is written. The editorial gives both versions and compares them.

Our version is about 85% the same as the reported question.

Given the root of a binary tree, return true if it is a sum tree, and false otherwise.

In a sum tree, every node that has at least one child holds exactly the sum of all values below it: every value in its left subtree plus every value in its right subtree. A node is compared with everything below it, not just with its two children. A leaf (a node with no children) needs no check, so it may hold any value.

Function

isSumTree(root: TreeNode) → boolean

Examples

Example 1

root = [26,10,3,4,6,null,3]return = true
root
26104633

10 has 4 and 6 below it, and 4 + 6 = 10. 3 has only 3 below it. The root has 10 + 4 + 6 + 3 + 3 = 26 below it. Leaves need no check, so the answer is true.

Example 2

root = [12,5,1,2,3]return = false
root
125231

5 has 2 and 3 below it, which add up to 5. But the root 12 has 5 + 2 + 3 + 1 = 11 below it, not 12, so the answer is false.

Example 3

root = [-4]return = true
root
-4

A single node is a leaf, and a leaf needs no check, so the answer is true whatever its value.

Constraints

  • The tree has 1 to 500 nodes.
  • -2^31 <= Node.val <= 2^31 - 1

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Binary Tree Target-Sum PathsByteDance · PHONE SCREENByteDance interview questions
  • Count Uni-Valued SubtreesAmazon · PHONE SCREEN
  • Validate Binary Search TreeLyft · PHONE SCREENLyft interview questions
  • Lowest Common Ancestor in a Binary TreeGoogle · PHONE SCREENGoogle interview questions
  • Maximum Value in a Binary TreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Sum Root-to-Leaf NumbersMeta · ONSITE INTERVIEWMeta interview questions
  • Validate Binary Search TreeGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Balanced Tree Node ReportNetflix · ONSITE INTERVIEWNetflix interview questions
  • Trim a Binary Search TreeBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Height-Balanced Binary TreeExpedia · ONSITE INTERVIEWExpedia interview questions

Interview reports that mention this question

  • Adobe CS1 Interviews: 14 Experiences (Part 4 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public boolean isSumTree(TreeNode root) {
        // Write your code here.
    }
}
Checking account…