Tree | LeetCode Problems

130 Tree solutions to LeetCode solutions.

Tree Problems View all solutions →

Binary Tree Inorder Traversal

#94 Easy

Unique Binary Search Trees II

#95 Medium

Unique Binary Search Trees

#96 Medium

Validate Binary Search Tree

#98 Medium

Recover Binary Search Tree

#99 Medium

Same Tree

#100 Easy

Symmetric Tree

#101 Easy

Binary Tree Level Order Traversal

#102 Medium

Binary Tree Zigzag Level Order Traversal

#103 Medium

Maximum Depth of Binary Tree

#104 Easy

Construct Binary Tree from Preorder and Inorder Traversal

#105 Medium

Construct Binary Tree from Inorder and Postorder Traversal

#106 Medium

Binary Tree Level Order Traversal II

#107 Medium

Convert Sorted Array to Binary Search Tree

#108 Easy

Convert Sorted List to Binary Search Tree

#109 Medium

Balanced Binary Tree

#110 Easy

Minimum Depth of Binary Tree

#111 Easy

Path Sum

#112 Easy

Path Sum II

#113 Medium

Flatten Binary Tree to Linked List

#114 Medium

Populating Next Right Pointers in Each Node

#116 Medium

Populating Next Right Pointers in Each Node II

#117 Medium

Binary Tree Maximum Path Sum

#124 Hard

Sum Root to Leaf Numbers

#129 Medium

Binary Tree Preorder Traversal

#144 Easy

Binary Tree Postorder Traversal

#145 Easy

Binary Search Tree Iterator

#173 Medium

Binary Tree Right Side View

#199 Medium

Count Complete Tree Nodes

#222 Easy

Invert Binary Tree

#226 Easy

Kth Smallest Element in a BST

#230 Medium

Lowest Common Ancestor of a Binary Search Tree

#235 Easy

Lowest Common Ancestor of a Binary Tree

#236 Medium

Binary Tree Paths

#257 Easy

Serialize and Deserialize Binary Tree

#297 Hard

Verify Preorder Serialization of a Binary Tree

#331 Medium

House Robber III

#337 Medium

Flatten Nested List Iterator

#341 Medium

Sum of Left Leaves

#404 Easy

Construct Quad Tree

#427 Medium

N-ary Tree Level Order Traversal

#429 Medium

Path Sum III

#437 Medium

Serialize and Deserialize BST

#449 Medium

Delete Node in a BST

#450 Medium

Find Mode in Binary Search Tree

#501 Easy

Most Frequent Subtree Sum

#508 Medium

Find Bottom Left Tree Value

#513 Medium

Find Largest Value in Each Tree Row

#515 Medium

Minimum Absolute Difference in BST

#530 Easy

Convert BST to Greater Tree

#538 Medium

Diameter of Binary Tree

#543 Easy

Logical OR of Two Binary Grids Represented as Quad-Trees

#558 Medium

Maximum Depth of N-ary Tree

#559 Easy

Binary Tree Tilt

#563 Easy

Subtree of Another Tree

#572 Easy

N-ary Tree Preorder Traversal

#589 Easy

N-ary Tree Postorder Traversal

#590 Easy

Construct String from Binary Tree

#606 Easy

Merge Two Binary Trees

#617 Easy

Add One Row to Tree

#623 Medium

Average of Levels in Binary Tree

#637 Easy

Find Duplicate Subtrees

#652 Medium

Two Sum IV - Input is a BST

#653 Easy

Maximum Binary Tree

#654 Medium

Print Binary Tree

#655 Medium

Maximum Width of Binary Tree

#662 Medium

Trim a Binary Search Tree

#669 Medium

Second Minimum Node In a Binary Tree

#671 Easy

Longest Univalue Path

#687 Medium

Employee Importance

#690 Medium

Search in a Binary Search Tree

#700 Easy

Insert into a Binary Search Tree

#701 Medium

Kth Largest Element in a Stream

#703 Easy

Minimum Distance Between BST Nodes

#783 Easy

Binary Tree Pruning

#814 Medium

Sum of Distances in Tree

#834 Hard

All Nodes Distance K in Binary Tree

#863 Medium

Smallest Subtree with all the Deepest Nodes

#865 Medium

Leaf-Similar Trees

#872 Easy

Construct Binary Tree from Preorder and Postorder Traversal

#889 Medium

All Possible Full Binary Trees

#894 Medium

Increasing Order Search Tree

#897 Easy

Complete Binary Tree Inserter

#919 Medium

Range Sum of BST

#938 Easy

Flip Equivalent Binary Trees

#951 Medium

Check Completeness of a Binary Tree

#958 Medium

Univalued Binary Tree

#965 Easy

Binary Tree Cameras

#968 Hard

Flip Binary Tree To Match Preorder Traversal

#971 Medium

Distribute Coins in Binary Tree

#979 Medium

Vertical Order Traversal of a Binary Tree

#987 Hard

Smallest String Starting From Leaf

#988 Medium

Cousins in Binary Tree

#993 Easy

Maximum Binary Tree II

#998 Medium

Construct Binary Search Tree from Preorder Traversal

#1008 Medium

Sum of Root To Leaf Binary Numbers

#1022 Easy

Maximum Difference Between Node and Ancestor

#1026 Medium

Recover a Tree From Preorder Traversal

#1028 Hard

Binary Search Tree to Greater Sum Tree

#1038 Medium

Insufficient Nodes in Root to Leaf Paths

#1080 Medium

Path In Zigzag Labelled Binary Tree

#1104 Medium

Delete Nodes And Return Forest

#1110 Medium

Lowest Common Ancestor of Deepest Leaves

#1123 Medium

Binary Tree Coloring Game

#1145 Medium

Maximum Level Sum of a Binary Tree

#1161 Medium

Find Elements in a Contaminated Binary Tree

#1261 Medium

Deepest Leaves Sum

#1302 Medium

All Elements in Two Binary Search Trees

#1305 Medium

Sum of Nodes with Even-Valued Grandparent

#1315 Medium

Delete Leaves With a Given Value

#1325 Medium

Maximum Product of Splitted Binary Tree

#1339 Medium

Validate Binary Tree Nodes

#1361 Medium

Linked List in Binary Tree

#1367 Medium

Longest ZigZag Path in a Binary Tree

#1372 Medium

Maximum Sum BST in Binary Tree

#1373 Hard

Time Needed to Inform All Employees

#1376 Medium

Frog Position After T Seconds

#1377 Hard

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

#1379 Easy

Balance a Binary Search Tree

#1382 Medium

Minimum Time to Collect All Apples in a Tree

#1443 Medium

Count Good Nodes in Binary Tree

#1448 Medium

Pseudo-Palindromic Paths in a Binary Tree

#1457 Medium

Kth Ancestor of a Tree Node

#1483 Hard

Number of Nodes in the Sub-Tree With the Same Label

#1519 Medium

Number of Good Leaf Nodes Pairs

#1530 Medium

Number of Ways to Reorder Array to Get Same BST

#1569 Hard

Throne Inheritance

#1600 Medium

Even Odd Tree

#1609 Medium

Count Subtrees With Max Distance Between Cities

#1617 Hard

Most Profitable Path in a Tree

#2467 Medium