FastPrepIs This Binary Tree a Max-Heap?
Problems/Is This Binary Tree a Max-Heap?

Is This Binary Tree a Max-Heap?

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem checks if a binary tree is a max-heap: complete, with every parent at least as large as its children. The same Adobe MTS 2 report from Noida (posted October 2024) that gives our character-frequency problem lists this as the second question of that first problem-solving round. The candidate named the two conditions a heap must meet and told the interviewer the problem was familiar, so a different problem followed. No code, limits or examples are reported.

Our choices: a max-heap, not a min-heap. Equal parent and child values are allowed. Trees have 1 to 2000 nodes with values from -10^4 to 10^4. The examples are new.

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

Given the root of a binary tree, return true if the tree is a max-heap and false otherwise. A binary tree is a max-heap when both of these hold:

  • It is complete: every level is full except possibly the last, and the nodes of the last level are as far left as possible (no gaps).
  • It is in heap order: every node's value is greater than or equal to the values of its children.

Function

isMaxHeap(root: TreeNode) → boolean

Examples

Example 1

root = [50,30,40,10,20,35]return = true
root
503010204035

Every level is full except the last, which is filled from the left (10, 20, 35). Each parent is at least as large as its children: 50 over 30 and 40, 30 over 10 and 20, 40 over 35. So it is a max-heap.

Example 2

root = [50,30,40,null,20]return = false
root
50302040

The values are in heap order, but 30 has a right child and no left child. The last level is not filled from the left, so the tree is not complete and not a heap.

Example 3

root = [7,7,9]return = false
root
779

The tree is complete, but the right child 9 is larger than its parent 7, so heap order fails. (Equal values, like the left child 7, are allowed.)

Constraints

  • The tree has between 1 and 2000 nodes.
  • -10^4 <= node.val <= 10^4
  • The tree does not have to be balanced. It can be a single chain of 2000 nodes.

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

  • Validate a Max HeapRippling · OARippling interview questions
  • Cheapest Flights Within K StopsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Top K Pins with Insert and QueryPinterest · PHONE SCREENPinterest interview questions
  • Maximum-Scoring Consecutive Tree LevelsJane Street · PHONE SCREENJane Street interview questions
  • Minimum Edits to a Perfect Binary TreeSnowflake · PHONE SCREENSnowflake interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Check a Complete Binary TreeGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Binary Tree Right Side ViewGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Same Binary TreeOdoo · PHONE SCREENOdoo interview questions

Interview reports that mention this question

  • Adobe MTS Interview Questions: 12 Experiences (Part 2 of 6)
  • Adobe Experienced Hire Interviews: 55 Experiences (Part 1 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
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 isMaxHeap(TreeNode root) {
        // Write your code here.
    }
}
Checking account…