FastPrepBinary Tree Level-Order Traversal by Levels
Problems/Binary Tree Level-Order Traversal by Levels

Binary Tree Level-Order Traversal by Levels

Adobe logoAdobe● EasyFULLTIMEINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report asks for a breadth-first walk that records the queue size for each level. It does not say what shape to return. Our version is about 95% the same as the reported question.

You are given the root of a binary tree. Return its values level by level (breadth-first level order), as a two-dimensional array.

  • The outer array starts with the root's level and goes down one level at a time.
  • Each inner array holds the values of one level, from left to right.
  • If root is null, return an empty array.

Function

levelOrderByLevels(root: TreeNode) → int[][]

Examples

Example 1

root = [3,9,20,null,null,15,7]return = [[3],[9,20],[15,7]]
root
3920157

The top level holds only the root. The next level holds 9 and 20, from left to right. The last level holds 15 and 7, the children of the right node. So the answer has three inner arrays, one for each level.

Example 2

root = []return = []
root
empty

An empty tree has no levels.

Constraints

  • 0 <= number of nodes <= 100000.
  • Every node value fits in a signed 32-bit integer.
  • The tree is finite and has no cycles.

More Adobe interview questions

  • Lowest Common Ancestor Only When Both Targets ExistONSITE INTERVIEW · Seen Aug 2026
  • Lowest Common Ancestor with Parent PointersONSITE INTERVIEW · Seen Aug 2026
  • Next and Previous Lexicographic PermutationONSITE INTERVIEW · Seen Aug 2026
  • Asteroid CollisionONSITE INTERVIEW · Seen Aug 2026
  • Farthest Affordable Shop per QueryONSITE INTERVIEW · Seen Aug 2026
  • Minimum Removals for a Nice ArrayONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Trie: Add and Search WordsONSITE INTERVIEW · Seen Jul 2026
  • Base Unit ConversionsOA · Seen Nov 2026
  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Breadth-First Values of a Binary TreeFigma · ONSITE INTERVIEWFigma interview questions
  • Zigzag Level-Order TraversalFlipkart · ONSITE INTERVIEW
  • Binary Tree Zigzag Level Order TraversalLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Binary Tree Zigzag Level Order TraversalMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Top View of a Binary TreeCapillary Technologies · ONSITE INTERVIEWCapillary Technologies interview questions
  • Independent Level Iterators Over a Shared Binary TreeGoogle · PHONE SCREENGoogle interview questions
  • Symmetric Binary TreeDocuSign · PHONE SCREENDocuSign interview questions
  • Nodes at a Given N-ary Tree LevelAmazon · PHONE SCREEN
  • Tree Level with the Most NodesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Left View of a Binary TreeMygate · PHONE SCREENMygate interview questions

Interview reports that mention this question

  • Adobe SWE Intern Interviews: 27 Experiences (Part 2 of 4)
  • Adobe Intern Interview Questions: 54 Experiences (Part 1 of 4)
  • Adobe MTS Interview Questions: 12 Experiences (Part 2 of 6)
  • Adobe Experienced Hire Interviews: 55 Experiences (Part 1 of 6)
  • Adobe Frontend Round 1 Questions: 10 Experiences (Part 9 of 12)

Adobe interview experiences

  • Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
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 int[][] levelOrderByLevels(TreeNode root) {
        // TODO: return one row per breadth-first level.
    }
}
Checking account…