Balanced Binary Tree (LeetCode 110) is a standard interview problem often associated with Spotify coding interviews, focusing on Tree, DFS, and Binary Tree concepts. It requires checking if a binary tree is height-balanced, where the height difference between left and right subtrees of every node is at most 1. This matches the tags and context from search results on Spotify engineer interviews.[1][2][3]
Given the root of a binary tree, determine if it is height-balanced.
A binary tree is height-balanced if for every node, the absolute difference in heights between its left and right subtrees is at most 1.
true if balanced, false otherwise.[2][3]Input:
3 / \ 9 20 / \ 15 7
Output: true
Explanation: All subtree height differences ≤ 1.[2]
Input:
1 / \ 2 2 / \ 3 3 / 4
Output: false
Explanation: Node with value 2 has left height 0 and right height 2 (diff > 1).[2]
Input: [1]
Output: true
Explanation: Trivial case, balanced by definition.[2]
root = null).[2]