Tree problems in Python
Walk, measure and search hierarchies in Python, on tree problems with tests that check your code.
Beginner
Intermediate
- 54. Mirror a TreeFlip a tree as if it stood in front of a mirror55 XP8 min
- 66. Root-to-Leaf Path SumIs there a way down the tree that adds up exactly?60 XP10 min
- 70. Level Order TraversalRead a tree one floor at a time65 XP10 min
- 95. Right Side ViewWhat do you see standing to the right of a tree?75 XP12 min
- 98. Folder SizesHow much space does each folder really take up?80 XP15 min
- 110. Valid Binary Search TreeIs this search tree really in order?85 XP14 min
- 290. Symmetric TreeWould this tree look the same in a mirror?65 XP12 min
- 297. Balanced Binary TreeDoes any branch of this tree grow too long?70 XP13 min
- 308. Root-to-Leaf PathsEvery way down a tree, written out in full70 XP12 min
Advanced
- 127. Diameter of a TreeThe longest walk between any two nodes of a tree120 XP20 min
- 138. Lowest Common AncestorWhere do the paths to two nodes split apart?125 XP20 min
- 166. Rebuild a Tree from TraversalsRecover a whole tree from two lists of its values160 XP30 min
- 363. Vertical Order of a TreeRead a tree column by column, from left to right125 XP25 min
- 402. Where to Put the ServerWhere should the server sit so that no office is too far away?145 XP30 min
Expert
- 172. Save and Restore a TreePack a tree into text and unpack it without losing a branch195 XP35 min
- 180. Maximum Path SumThe richest route through a tree, starting and ending anywhere215 XP35 min
- 441. Cameras on a TreeWatch every corner of a tree with as few cameras as possible220 XP40 min
- 448. Same Shape TreesTwo family trees: the same shape underneath?220 XP45 min
- 472. Sum of Distances in a TreeHow far is every village from all the others?240 XP45 min
Other topics
- Python Basics
- Strings
- Lists
- Dictionaries and sets
- Loops
- Functions
- Math
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Dynamic programming
- Greedy
- Graphs
- Bit manipulation
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.