FastPrepBreadth-First Values of a Binary Tree
Problems/Breadth-First Values of a Binary Tree

Breadth-First Values of a Binary Tree

Figma logoFigma● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Figma software-engineering intern onsite report names one technical question only as BFS with a tree. It did not share the traversal result, the child order, the interface, examples, what happens with an empty tree, or the limits. Our version is about 60% the same as the reported question.

Given the root of a binary tree, return its node values in breadth-first order.

Visit nodes level by level from top to bottom, and from left to right within each level. Return an empty array for an empty tree.

Function

breadthFirstValues(root: TreeNode) → int[]

Examples

Example 1

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

The traversal visits the root, then 9 and 20, then 15 and 7.

Example 2

root = [1,2,3,4,5]return = [1,2,3,4,5]
root
12453

Values on the same level are emitted from left to right.

Example 3

root = []return = []
root
empty

An empty tree has no values to visit.

Constraints

  • The tree contains at most 100000 nodes.
  • Each node value fits in a signed 32-bit integer.

More Figma Onsite Interview questions

  • Recursive Display SortPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Rich Text Parser Part 3 (Depth Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rich Text Parser Part 2 (Parse Nested Groups)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rich Text Parser Part 1 (Validate Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Table Selection and Color UpdatesPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Sort Documents Left to RightONSITE INTERVIEW · Seen Aug 2026
  • Symmetric Binary TreeONSITE INTERVIEW · Seen Feb 2026
  • Topmost Accessible NodesPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2025
  • Nested Template Variable ExpansionONSITE INTERVIEW · Seen Jun 2024
  • Parse, Validate, and Repair Markdown FormattingONSITE INTERVIEW · Seen Jun 2024

Similar questions at other companies

  • Binary Tree Level-Order Traversal by LevelsAdobe · PHONE SCREEN · ONSITE INTERVIEWAdobe 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
  • Check Whether All Leaves Are at the Same LevelAmazon · ONSITE INTERVIEW
  • Tree Level with the Most NodesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Mirror Image Binary TreesExpedia · ONSITE INTERVIEWExpedia interview questions
  • Mirror a Binary TreeAMD · ONSITE INTERVIEWAMD interview questions

Interview reports that mention this question

  • Figma SWE Intern OA and Final Round: 21 Experiences
  • Figma SWE Intern OA Questions: 25 Experiences

Figma interview experiences

  • Figma interviews · November 2026
All Figma interview questionsSee Figma 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[] breadthFirstValues(TreeNode root) {
        // Write your code here.
    }
}
Checking account…