binary tree
binary tree is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Binary Tree Inorder Traversal
Binary Tree Inorder Traversal asks you to visit left subtree, node, then right subtree without losing position while mov…
Unique Binary Search Trees II
Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.
Unique Binary Search Trees
Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.
Validate Binary Search Tree
Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…
Recover Binary Search Tree
Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…
Same Tree
Check whether two binary trees are identical by comparing structure and node values using DFS or BFS traversal strategie…
Symmetric Tree
Determine if a binary tree is symmetric by comparing left and right subtrees using DFS or BFS traversal techniques effic…
Binary Tree Level Order Traversal
Perform a level order traversal on a binary tree using BFS to return node values level by level.
Binary Tree Zigzag Level Order Traversal
Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…
Maximum Depth of Binary Tree
Find the maximum depth of a binary tree using traversal techniques to track the longest path from root to leaf.
Construct Binary Tree from Preorder and Inorder Traversal
Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.
Construct Binary Tree from Inorder and Postorder Traversal
Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…
Binary Tree Level Order Traversal II
Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…
Convert Sorted Array to Binary Search Tree
Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.
Convert Sorted List to Binary Search Tree
Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…
Balanced Binary Tree
Determine if a binary tree is height-balanced using tree traversal and state tracking techniques.
Minimum Depth of Binary Tree
Find the minimum depth of a binary tree, which is the shortest path from the root node to the nearest leaf node.
Path Sum
Determine if a binary tree has a root-to-leaf path where the sum of node values equals a given target sum, using DFS or …
Path Sum II
Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.
Flatten Binary Tree to Linked List
Flatten a binary tree into a right-skewed linked list by manipulating pointers following a pre-order traversal, handling…
Populating Next Right Pointers in Each Node
Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…
Populating Next Right Pointers in Each Node II
Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…
Binary Tree Maximum Path Sum
Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…
Sum Root to Leaf Numbers
Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.
Binary Tree Preorder Traversal
Perform a binary tree preorder traversal by visiting root nodes first, then left and right subtrees, tracking state iter…
Binary Tree Postorder Traversal
Solve Binary Tree Postorder Traversal using state tracking and binary-tree traversal techniques, focusing on Stack, Tree…
Binary Search Tree Iterator
Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…
Binary Tree Right Side View
The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…
Count Complete Tree Nodes
Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…
Invert Binary Tree
Invert Binary Tree swaps every node's left and right children using tree traversal, with recursive DFS or iterative BFS …
Kth Smallest Element in a BST
Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.
Lowest Common Ancestor of a Binary Search Tree
Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…
Lowest Common Ancestor of a Binary Tree
Identify the lowest common ancestor of two nodes in a binary tree using traversal and state tracking techniques efficien…
Binary Tree Paths
Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…
Serialize and Deserialize Binary Tree
This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…
Verify Preorder Serialization of a Binary Tree
Determine if a given string correctly represents a binary tree preorder traversal using state tracking and slot counting…
House Robber III
Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.
Sum of Left Leaves
Compute the total of all left leaves in a binary tree using precise traversal and state tracking techniques for correctn…
Path Sum III
Path Sum III challenges you to count paths in a binary tree that sum to a given target value with downward traversal.
Serialize and Deserialize BST
Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.
Delete Node in a BST
Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…
Find Mode in Binary Search Tree
Find Mode in Binary Search Tree asks to identify the most frequent element(s) in a BST using binary-tree traversal.
Most Frequent Subtree Sum
Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…
Find Bottom Left Tree Value
Find the leftmost value in the last row of a binary tree using efficient traversal strategies.
Find Largest Value in Each Tree Row
Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.
Minimum Absolute Difference in BST
Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…
Convert BST to Greater Tree
Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.
Diameter of Binary Tree
The Diameter of Binary Tree problem involves finding the longest path between any two nodes using tree traversal techniq…
Binary Tree Tilt
Calculate the sum of the binary tree's node tilts using tree traversal and state tracking.
Subtree of Another Tree
Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.
Construct String from Binary Tree
Given a binary tree, construct a string representation based on preorder traversal while adhering to specific formatting…
Merge Two Binary Trees
Merge Two Binary Trees requires combining nodes by summing overlapping values while preserving non-null nodes from eithe…
Add One Row to Tree
The problem requires adding a row of nodes to a binary tree at a specified depth.
Average of Levels in Binary Tree
Calculate the average value of nodes on each level of a binary tree using traversal and state tracking.
Find Duplicate Subtrees
Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…
Two Sum IV - Input is a BST
Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…
Maximum Binary Tree
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
Print Binary Tree
Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…
Maximum Width of Binary Tree
Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…
Trim a Binary Search Tree
Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.
Second Minimum Node In a Binary Tree
Find the second minimum node in a binary tree by traversing the tree and tracking state.
Longest Univalue Path
Find the longest path in a binary tree where all nodes share the same value using depth-first search efficiently.
Search in a Binary Search Tree
Locate a target value in a binary search tree and return the subtree rooted at that node using efficient tree traversal …
Insert into a Binary Search Tree
Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…
Kth Largest Element in a Stream
Find the kth largest element in a dynamic stream using binary-tree traversal and efficient state tracking with a min-hea…
Minimum Distance Between BST Nodes
Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…
Binary Tree Pruning
Binary Tree Pruning removes subtrees not containing a 1, applying binary-tree traversal with state tracking.
All Nodes Distance K in Binary Tree
Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.
Smallest Subtree with all the Deepest Nodes
Find the smallest subtree that contains all the deepest nodes in a binary tree.
Leaf-Similar Trees
Determine if two binary trees have identical leaf sequences using efficient traversal and state tracking techniques.
Construct Binary Tree from Preorder and Postorder Traversal
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
All Possible Full Binary Trees
Generate all possible full binary trees with n nodes, focusing on dynamic programming and binary tree traversal.
Increasing Order Search Tree
Rearrange a binary search tree so all nodes follow increasing order with only right children using in-order traversal.
Complete Binary Tree Inserter
Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.
Range Sum of BST
Given a BST and a range, calculate the sum of all node values within that range.
Flip Equivalent Binary Trees
Determine if two binary trees are flip equivalent by recursively swapping subtrees.
Check Completeness of a Binary Tree
Determine if a binary tree is complete by verifying its node structure and leftmost placement in the last level.
Univalued Binary Tree
Determine if a binary tree is uni-valued using traversal and state tracking techniques.
Binary Tree Cameras
Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…
Flip Binary Tree To Match Preorder Traversal
Determine the minimum set of nodes to flip in a binary tree so its pre-order traversal matches a given voyage sequence.
Distribute Coins in Binary Tree
Minimize the number of moves needed to distribute coins in a binary tree so that each node has exactly one coin.
Vertical Order Traversal of a Binary Tree
Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.
Smallest String Starting From Leaf
Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…
Cousins in Binary Tree
Determine if two nodes in a binary tree are cousins by leveraging binary-tree traversal and state tracking.
Maximum Binary Tree II
The Maximum Binary Tree II problem requires building a binary tree by inserting a value into a maximum binary tree while…
Construct Binary Search Tree from Preorder Traversal
Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.
Sum of Root To Leaf Binary Numbers
Calculate the sum of binary numbers from root to leaf paths in a binary tree.
Maximum Difference Between Node and Ancestor
Find the maximum absolute difference between a node and its ancestor in a binary tree.
Recover a Tree From Preorder Traversal
Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…
Binary Search Tree to Greater Sum Tree
Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…
Insufficient Nodes in Root to Leaf Paths
Remove nodes in a binary tree whose all root-to-leaf paths sum to less than a given limit using DFS traversal and state …
Path In Zigzag Labelled Binary Tree
The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.
Delete Nodes And Return Forest
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
Lowest Common Ancestor of Deepest Leaves
Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…
Binary Tree Coloring Game
A two-player game where players color nodes in a binary tree, aiming to outmaneuver each other by choosing adjacent node…
Maximum Level Sum of a Binary Tree
Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.
Find Elements in a Contaminated Binary Tree
Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…
Deepest Leaves Sum
Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.
All Elements in Two Binary Search Trees
Merge elements from two binary search trees and return them sorted in ascending order.
Sum of Nodes with Even-Valued Grandparent
This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.
Delete Leaves With a Given Value
In this problem, you need to delete all leaf nodes in a binary tree with a given target value, performing continuous del…
Maximum Product of Splitted Binary Tree
Maximize the product of sums of two subtrees formed by splitting a binary tree.
Validate Binary Tree Nodes
Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.
Linked List in Binary Tree
Determine if a linked list is represented as a downward path in a binary tree using pointer traversal and recursive chec…
Longest ZigZag Path in a Binary Tree
Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…
Maximum Sum BST in Binary Tree
Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.
Find a Corresponding Node of a Binary Tree in a Clone of That Tree
Find the corresponding node in a cloned binary tree using binary-tree traversal and state tracking.
Balance a Binary Search Tree
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
Count Good Nodes in Binary Tree
Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…
Pseudo-Palindromic Paths in a Binary Tree
Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.
Number of Good Leaf Nodes Pairs
Find the number of good leaf node pairs in a binary tree where the shortest path between them is less than or equal to a…
Number of Ways to Reorder Array to Get Same BST
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
Even Odd Tree
Determine if a binary tree meets Even-Odd rules by checking value parity and strict ordering at each level efficiently.
Merge BSTs to Create Single BST
This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.
Count Nodes With the Highest Score
Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.
Step-By-Step Directions From a Binary Tree Node to Another
Find the shortest path between two nodes in a binary tree and output the directions as a string of 'L', 'R', and 'U'.
Create Binary Tree From Descriptions
Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.
Root Equals Sum of Children
Check if a binary tree root value equals the sum of its immediate left and right child nodes efficiently.
Count Nodes Equal to Average of Subtree
Given a binary tree, count nodes where the value equals the average of values in its subtree.
Evaluate Boolean Binary Tree
Determine the boolean outcome of a full binary tree by evaluating leaf and internal nodes using depth-first traversal.
Amount of Time for Binary Tree to Be Infected
The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…
Reverse Odd Levels of Binary Tree
Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.
Height of Binary Tree After Subtree Removal Queries
Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…
Minimum Number of Operations to Sort a Binary Tree by Level
Determine the minimum number of swaps to sort each level of a binary tree using level-wise traversal efficiently.
Closest Nodes Queries in a Binary Search Tree
Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…
Cycle Length Queries in a Tree
Solve the problem of determining cycle lengths in a binary tree with added edges through queries.
Kth Largest Sum in a Binary Tree
Find the kth largest level sum in a binary tree using level-order traversal and sorting.
Cousins in Binary Tree II
Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.
Make Costs of Paths Equal in a Binary Tree
Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.
K-th Largest Perfect Subtree Size in Binary Tree
Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.