Workspace

Trees

3 day streakD
All algorithms

Tree algorithms.

Understand the recursion, follow each branch, then put it into code.

28 lessons · Python & C++

Traversals

Tree properties

Paths & ancestors

ProblemDifficultyTime complexityPractice
Root-to-Leaf PathsEasyO(n + L)LeetCode
Root-to-Leaf Path SumEasyO(n)LeetCode
Lowest Common AncestorMediumO(n)LeetCode
Nodes at Distance KMediumO(n)LeetCode

Views

ProblemDifficultyTime complexityPractice
Right Side ViewMediumO(n)LeetCode
Boundary TraversalMediumO(n)GFG
Vertical Order TraversalHardO(n log n)LeetCode

Binary search trees

ProblemDifficultyTime complexityPractice
Search in a BSTEasyO(h)LeetCode
Insert into a BSTMediumO(h)LeetCode
Delete from a BSTMediumO(h)LeetCode
Validate a BSTMediumO(n)LeetCode
Kth Smallest in a BSTMediumO(h + k)LeetCode

Construction

ProblemDifficultyTime complexityPractice
Build from Preorder & InorderMediumO(n)LeetCode
Serialize & DeserializeHardO(n)LeetCode
Flatten to a Linked ListMediumO(n)LeetCode

A good place to start

Explore a pattern

A little guidance

Start with a pattern, read through a problem, and mark it solved when the idea clicks. Save anything you want to revisit.

New tutorials are added one at a time. Your bookmarks and solved checkmarks stay in this browser.

Explore the roadmap