FastPrepInvert Binary Tree
Problems/Invert Binary Tree

Invert Binary Tree

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Bloomberg new-grad report names the standard Invert Binary Tree exercise directly. Our version is about 100% the same as the reported question.

Given the root of a binary tree, invert the tree by swapping the left and right child of every node. Return the root of the inverted tree.

Function

invertTree(root: TreeNode) → TreeNode

Examples

Example 1

root = [4,2,7,1,3,6,9]return = [4,7,2,9,6,3,1]
root
4213769
→
return
4796231
Moved or new

Every node's two child links are swapped.

Example 2

root = []return = []
root
empty
return
empty

An empty tree remains empty.

Constraints

  • The tree contains between 0 and 10^5 nodes.
  • -10^9 <= Node.val <= 10^9.

More Bloomberg LP Phone Screen questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Merge Two Binary TreesSnowflake · PHONE SCREENSnowflake interview questions
  • Sum All Values in a Binary TreeDuolingo · PHONE SCREENDuolingo interview questions
  • Sum Root-to-Leaf Binary NumbersOracle · PHONE SCREENOracle interview questions
  • Symmetric Binary TreeDocuSign · PHONE SCREENDocuSign interview questions
  • Count One-Valued Regions in a Binary TreeGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximum Depth of Binary TreeLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Maximum Value in a Binary TreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Root-to-Leaf Paths as StringsAdobe · PHONE SCREENAdobe interview questions
  • Org Chart Report CountsPatreon · PHONE SCREENPatreon interview questions
  • Left View of a Binary TreeMygate · PHONE SCREENMygate interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP 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 TreeNode invertTree(TreeNode root) {
        // Write your code here.
    }

}
Checking account…