Solution for Tree


33
82
11
# Name Difficulty Tags
94 Binary Tree Inorder Traversal Medium Tree | Hash Table | Stack
95 Unique Binary Search Trees II Medium Dynamic Programming | Tree
96 Unique Binary Search Trees Medium Dynamic Programming | Tree
98 Validate Binary Search Tree Medium Tree | Depth-first Search
99 Recover Binary Search Tree Hard Tree | Depth-first Search
100 Same Tree Easy Tree | Depth-first Search
101 Symmetric Tree Easy Tree | Depth-first Search | Breadth-first Search
102 Binary Tree Level Order Traversal Medium Tree | Breadth-first Search
103 Binary Tree Zigzag Level Order Traversal Medium Stack | Tree | Breadth-first Search
104 Maximum Depth of Binary Tree Easy Tree | Depth-first Search
105 Construct Binary Tree from Preorder and Inorder Traversal Medium Array | Tree | Depth-first Search
106 Construct Binary Tree from Inorder and Postorder Traversal Medium Array | Tree | Depth-first Search
107 Binary Tree Level Order Traversal II Medium Tree | Breadth-first Search
108 Convert Sorted Array to Binary Search Tree Easy Tree | Depth-first Search
110 Balanced Binary Tree Easy Tree | Depth-first Search
111 Minimum Depth of Binary Tree Easy Tree | Depth-first Search Breadth-first Search
112 Path Sum Easy Tree | Depth-first Search
113 Path Sum II Medium Tree | Depth-first Search
114 Flatten Binary Tree to Linked List Medium Tree | Depth-first Search
116 Populating Next Right Pointers in Each Node Medium Tree | Depth-first Search
117 Populating Next Right Pointers in Each Node II Medium Tree | Depth-first Search
124 Binary Tree Maximum Path Sum Hard Tree | Depth-first Search
129 Sum Root to Leaf Numbers Medium Tree | Depth-first Search
144 Binary Tree Preorder Traversal Medium Stack | Tree
145 Binary Tree Postorder Traversal Medium Tree | Stack
156 Binary Tree Upside Down Medium Tree
173 Binary Search Tree Iterator Medium Stack | Tree | Design
199 Binary Tree Right Side View Medium Tree | Depth-first Search | Breadth-first Search
222 Count Complete Tree Nodes Medium Binary Search | Tree
226 Invert Binary Tree Easy Tree
230 Kth Smallest Element in a BST Medium Binary Search | Tree
235 Lowest Common Ancestor of a Binary Search Tree Easy Tree
236 Lowest Common Ancestor of a Binary Tree Medium Tree
250 Count Univalue Subtrees Medium Tree
255 Verify Preorder Sequence in Binary Search Tree Medium Stack | Tree
257 Binary Tree Paths Easy Tree | Depth-first Search
270 Closest Binary Search Tree Value Easy Binary Search | Tree
272 Closest Binary Search Tree Value II Hard Stack | Tree
285 Inorder Successor in BST Medium Tree
297 Serialize and Deserialize Binary Tree Hard Tree | Design
298 Binary Tree Longest Consecutive Sequence Medium Tree
333 Largest BST Subtree Medium Tree
337 House Robber III Medium Tree | Depth-first Search
366 Find Leaves of Binary Tree Medium Tree | Depth-first Search
404 Sum of Left Leaves Easy Tree
426 Convert Binary Search Tree to Sorted Doubly Linked List Medium Linked List | Divide an Conquer | Tree
428 Serialize and Deserialize N-ary Tree Hard Tree
429 N-ary Tree Level Order Traversal Medium Tree | Breadth-first Search
431 Encode N-ary Tree to Binary Tree Hard Tree
437 Path Sum III Medium Tree
449 Serialize and Deserialize BST Medium Tree
450 Delete Node in a BST Medium Tree
501 Find Mode in Binary Search Tree Easy Tree
508 Most Frequent Subtree Sum Medium Hash Table | Tree
510 Inorder Successor in BST II Medium Tree
513 Find Bottom Left Tree Value Medium Tree | Depth-first Search | Breadth-first Search
515 Find Largest Value in Each Tree Row Medium Tree | Depth-first Search | Breadth-first Search
530 Minimum Absolute Difference in BST Easy Tree
536 Construct Binary Tree from String Medium String | Tree
538 Convert BST to Greater Tree Medium Tree
543 Diameter of Binary Tree Easy Tree
545 Boundary of Binary Tree Medium Tree
549 Binary Tree Longest Consecutive Sequence II Medium Tree
559 Maximum Depth of N-ary Tree Easy Tree | Depth-first Search | Breadth-first Search
563 Binary Tree Tilt Easy Tree
572 Subtree of Another Tree Easy Tree
582 Kill Process Medium Tree | Queue
589 N-ary Tree Preorder Traversal Easy Tree
590 N-ary Tree Postorder Traversal Easy Tree
606 Construct String from Binary Tree Easy String | Tree
617 Merge Two Binary Trees Easy Tree
623 Add One Row to Tree Medium Tree
637 Average of Levels in Binary Tree Easy Tree
652 Find Duplicate Subtrees Medium Tree
653 Two Sum IV - Input is a BST Easy Tree
654 Maximum Binary Tree Medium Tree
655 Print Binary Tree Medium Tree
662 Maximum Width of Binary Tree Medium Tree
663 Equal Tree Partition Medium Tree
666 Path Sum IV Medium Tree
669 Trim a Binary Search Tree Medium Tree
671 Second Minimum Node In a Binary Tree Easy Tree
687 Longest Univalue Path Medium Tree | Recursion
700 Search in a Binary Search Tree Easy Tree
701 Insert into a Binary Search Tree Medium Tree
742 Closest Leaf in a Binary Tree Medium Tree
776 Split BST Medium Tree | Recursion
783 Minimum Distance Between BST Nodes Easy Tree | Recursion
814 Binary Tree Pruning Medium Tree
834 Sum of Distances in Tree Hard Tree | Depth-first Search
863 All Nodes Distance K in Binary Tree Medium Tree | Depth-first Search | Breadth-first Search
865 Smallest Subtree with all the Deepest Nodes Medium Tree
872 Leaf-Similar Trees Easy Tree | Depth-first Search
889 Construct Binary Tree from Preorder and Postorder Traversal Medium Tree
894 All Possible Full Binary Trees Medium Tree | Recursion
897 Increasing Order Search Tree Easy Tree | Depth-first Search
919 Complete Binary Tree Inserter Medium Tree
938 Range Sum of BST Easy Tree | Recursion
951 Flip Equivalent Binary Trees Medium Tree
958 Check Completeness of a Binary Tree Medium Tree
965 Univalued Binary Tree Easy Tree
968 Binary Tree Cameras Hard Dynamic Programming | Tree | Depth-first Search
971 Flip Binary Tree To Match Preorder Traversal Medium Tree | Depth-first Search
979 Distribute Coins in Binary Tree Medium Tree | Depth-first Search
987 Vertical Order Traversal of a Binary Tree Hard Hash Table | Tree
988 Smallest String Starting From Leaf Medium Tree | Depth-first Search
993 Cousins in Binary Tree Easy Tree | Breadth-first Search
998 Maximum Binary Tree II Medium Tree
1008 Construct Binary Search Tree from Preorder Traversal Medium Tree
1022 Sum of Root To Leaf Binary Numbers Easy Tree
1026 Maximum Difference Between Node and Ancestor Medium Tree | Depth-first Search
1028 Recover a Tree From Preorder Traversal Hard Tree | Depth-first Search
1104 Path In Zigzag Labelled Binary Tree Medium Math | Tree
1110 Delete Nodes And Return Forest Medium Tree | Depth-first Search
1120 Maximum Average Subtree Medium Tree
1123 Lowest Common Ancestor of Deepest Leaves Medium Tree | Depth-first Search
1130 Minimum Cost Tree From Leaf Values Medium Dynamic Programming | Stack | Tree
1145 Binary Tree Coloring Game Medium Tree | Depth-first Search
1245 Tree Diameter Medium Tree | Depth-first Search | Breadth-first Search
1302 Deepest Leaves Sum Medium Tree | Depth-first Search
1305 All Elements in Two Binary Search Trees Medium Sort | Tree
1315 Sum of Nodes with Even-Valued Grandparent Medium Tree | Depth-first Search
1325 Delete Leaves With a Given Value Medium Tree
1339 Maximum Product of Splitted Binary Tree Medium Dynamic Programming | Tree
1367 Linked List in Binary Tree Medium Linked List | Dynamic Programming | Tree
1766 Tree of Coprimes Hard Math | Tree | Depth-first Search | Breadth-first Search