Tree Interview Questions

Binary trees, traversals, and hierarchical recursion.

120 problems

#Title
94Binary Tree Inorder Traversal
99Recover Binary Search Tree
144Binary Tree Preorder Traversal
145Binary Tree Postorder Traversal
208Implement Trie (Prefix Tree)
211Add and Search Word - Data structure design
226Invert Binary Tree
297Serialize and Deserialize Binary Tree
307Range Sum Query - Mutable
308Range Sum Query 2D - Mutable
315Count of Smaller Numbers After Self
426Convert Binary Search Tree to Sorted Doubly Linked List
427Construct Quad Tree
428Serialize and Deserialize N-ary Tree
429N-ary Tree Level Order Traversal
430Flatten a Multilevel Doubly Linked List
431Encode N-ary Tree to Binary Tree
501Find Mode in Binary Search Tree
508Most Frequent Subtree Sum
513Find Bottom Left Tree Value
529Minesweeper
536Construct Binary Tree from String
538Convert BST to Greater Tree
543Diameter of Binary Tree
545Boundary of Binary Tree
548Split Array with Equal Sum
558Logical OR of Two Binary Grids Represented as Quad-Trees
559Max Consecutive Ones
563Binary Tree Tilt
572Subtree of Another Tree
589N-ary Tree Preorder Traversal
590N-ary Tree Postorder Traversal
606Construct String from Binary Tree
617Merge Two Binary Trees
623Add One Row to Tree
637Average of Levels in Binary Tree
652Find Duplicate Subtrees
653Two Sum IV - Input is a BST
654Maximum Binary Tree
655Print Binary Tree
662Maximum Width of Binary Tree
663Equal Tree Partition
677Map Sum Pairs
684Redundant Connection
685Redundant Connection II
687Longest Univalue Path
699Falling Squares
700Search in a Binary Search Tree
701Insert into a Binary Search Tree
814Binary Tree Pruning
850Rectangle Area II
863All Nodes Distance K in Binary Tree
865Smallest Subtree with all the Deepest Nodes
889Construct Binary Tree from Preorder and Postorder Traversal
897Increasing Order Search Tree
919Complete Binary Tree Inserter
938Range Sum of BST
951Flip Equivalent Binary Trees
958Check Completeness of a Binary Tree
965Univalued Binary Tree
971Flip Binary Tree To Match Preorder Traversal
979Distribute Coins in Binary Tree
987Vertical Order Traversal of a Binary Tree
988Smallest String Starting From Leaf
993Cousins in Binary Tree
998Maximum Binary Tree II
1008Construct Binary Search Tree from Preorder Traversal
1022Sum of Root To Leaf Binary Numbers
1026Maximum Difference Between Node and Ancestor
1028Recover a Tree From Preorder Traversal
1032Stream of Characters
1038Binary Search Tree to Greater Sum Tree
1065Index Pairs of a String
1080Insufficient Nodes in Root to Leaf Paths
1104Path In Zigzag Labelled Binary Tree
1120Maximum Average Subtree
1123Lowest Common Ancestor of Deepest Leaves
1145Binary Tree Coloring Game
1257Smallest Common Region
1261Find Elements in a Contaminated Binary Tree
1325Delete Leaves With a Given Value
1339Maximum Product of Splitted Binary Tree
1409Queries on a Permutation With Key
1430Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
1443Minimum Time to Collect All Apples in a Tree
1448Count Good Nodes in Binary Tree
1457Pseudo-Palindromic Paths in a Binary Tree
1469Find All The Lonely Nodes
1490Clone N-ary Tree
1505Minimum Possible Integer After at Most K Adjacent Swaps On Digits
1506Find Root of N-Ary Tree
1516Move Sub-Tree of N-Ary Tree
1519Number of Nodes in the Sub-Tree With the Same Label
1522Diameter of N-Ary Tree
1530Number of Good Leaf Nodes Pairs
1612Check If Two Expression Trees are Equivalent
1649Create Sorted Array through Instructions
1666Change the Root of a Binary Tree
1834Single-Threaded CPU
1938Maximum Genetic Difference Query
1948Delete Duplicate Folders in System
2003Smallest Missing Genetic Value in Each Subtree
2096Step-By-Step Directions From a Binary Tree Node to Another
2179Count Good Triplets in an Array
2196Create Binary Tree From Descriptions
2236Root Equals Sum of Children
2277Closest Node to Path in Tree
2421Number of Good Paths
2509Cycle Length Queries in a Tree
2846Minimum Edge Weight Equilibrium Queries in a Tree
3109Find the Index of Permutation
3515Shortest Path in a Weighted Tree
3553Minimum Weighted Subgraph With the Required Paths II
3558Number of Ways to Assign Edge Weights I
3559Number of Ways to Assign Edge Weights II
3585Find Weighted Median Node in Tree
3715Sum of Perfect Square Ancestors
3841Palindromic Path Queries in a Tree
3879Maximum Distinct Path Sum in a Binary Tree
3973Distinct Gate Paths to LCA