← All topics

🌳 Interview Prep

Trees, Graphs & DP

Trees, heaps, tries, graphs, backtracking and dynamic programming: what separates a pass from a strong pass at big tech.

100 questions, most asked first

Ordered so the most useful questions for learning each pattern come first.

#1Maximum Depth of Binary TreeTree DFSEasyFree#2Invert Binary TreeTree DFSEasyFree#3Same TreeTree DFSEasyFree#4Binary Tree Level Order TraversalTree BFSMediumFree#5Validate Binary Search TreeBSTMediumFree#6Lowest Common Ancestor of a BSTBSTMediumFree#7Number of IslandsGrid graphMediumFree#8Climbing Stairs1D DPEasyFree#9Coin Change1D DPMediumFree#10Kth Largest Element in an ArrayHeapMediumFreeUnlock 90 more Trees, Graphs & DP questions Β· all 1,200 questions for $39/year (about 11Β’ a day)See full access#11Subtree of Another TreeTree DFSEasyπŸ”’#12Diameter of Binary TreeTree DFSEasyπŸ”’#13Balanced Binary TreeTree DFSEasyπŸ”’#14Binary Tree Right Side ViewTree BFSMediumπŸ”’#15Kth Smallest Element in a BSTBSTMediumπŸ”’#16Construct Binary Tree from Preorder and InorderTree DFSMediumπŸ”’#17Serialize and Deserialize Binary TreeTree BFSHardπŸ”’#18Binary Tree Maximum Path SumTree DFSHardπŸ”’#19Lowest Common Ancestor of a Binary TreeTree DFSMediumπŸ”’#20Clone GraphGraph BFS/DFSMediumπŸ”’#21Course ScheduleTopological sortMediumπŸ”’#22Course Schedule IITopological sortMediumπŸ”’#23Pacific Atlantic Water FlowGrid graphMediumπŸ”’#24Rotting OrangesGrid graphMediumπŸ”’#25Max Area of IslandGrid graphMediumπŸ”’#26Word SearchBacktrackingMediumπŸ”’#27SubsetsBacktrackingMediumπŸ”’#28PermutationsBacktrackingMediumπŸ”’#29Combination SumBacktrackingMediumπŸ”’#30Generate ParenthesesBacktrackingMediumπŸ”’#31House Robber1D DPMediumπŸ”’#32House Robber II1D DPMediumπŸ”’#33Longest Increasing Subsequence1D DPMediumπŸ”’#34Word Break1D DPMediumπŸ”’#35Decode Ways1D DPMediumπŸ”’#36Unique Paths2D DPMediumπŸ”’#37Longest Common Subsequence2D DPMediumπŸ”’#38Edit Distance2D DPMediumπŸ”’#39Longest Palindromic Substring2D DPMediumπŸ”’#40Palindromic Substrings2D DPMediumπŸ”’#41Implement Trie (Prefix Tree)TrieMediumπŸ”’#42Design Add and Search WordsTrieMediumπŸ”’#43Word Search IITrieHardπŸ”’#44Find Median from Data StreamHeapHardπŸ”’#45K Closest Points to OriginHeapMediumπŸ”’#46Last Stone WeightHeapEasyπŸ”’#47Task SchedulerHeapMediumπŸ”’#48Number of Connected Components in a GraphUnion-findMediumπŸ”’#49Graph Valid TreeUnion-findMediumπŸ”’#50Redundant ConnectionUnion-findMediumπŸ”’#51Network Delay TimeShortest pathMediumπŸ”’#52Cheapest Flights Within K StopsShortest pathMediumπŸ”’#53Word LadderGraph BFS/DFSHardπŸ”’#54Alien DictionaryTopological sortHardπŸ”’#55Surrounded RegionsGrid graphMediumπŸ”’#56Shortest Path in Binary MatrixGrid graphMediumπŸ”’#57N-QueensBacktrackingHardπŸ”’#58Letter Combinations of a Phone NumberBacktrackingMediumπŸ”’#59Combination Sum IIBacktrackingMediumπŸ”’#60Subsets IIBacktrackingMediumπŸ”’#61Palindrome PartitioningBacktrackingMediumπŸ”’#62Min Cost Climbing Stairs1D DPEasyπŸ”’#63Maximum Product Subarray1D DPMediumπŸ”’#64Partition Equal Subset Sum1D DPMediumπŸ”’#65Coin Change II1D DPMediumπŸ”’#66Target Sum1D DPMediumπŸ”’#67Minimum Path Sum2D DPMediumπŸ”’#68Longest Increasing Path in a Matrix2D DPHardπŸ”’#69Interleaving String2D DPMediumπŸ”’#70Best Time to Buy and Sell Stock with Cooldown2D DPMediumπŸ”’#71Maximal Square2D DPMediumπŸ”’#72Binary Tree Inorder Traversal (Iterative)Tree DFSEasyπŸ”’#73Symmetric TreeTree DFSEasyπŸ”’#74Path SumTree DFSEasyπŸ”’#75Path Sum IIBacktrackingMediumπŸ”’#76Count Good Nodes in Binary TreeTree DFSMediumπŸ”’#77Convert Sorted Array to Balanced BSTBSTEasyπŸ”’#78Delete Node in a BSTBSTMediumπŸ”’#79Insert into a BSTBSTMediumπŸ”’#80Binary Tree Zigzag Level Order TraversalTree BFSMediumπŸ”’#81Average of Levels in Binary TreeTree BFSEasyπŸ”’#82Minimum Depth of Binary TreeTree BFSEasyπŸ”’#83Flatten Binary Tree to Linked ListTree DFSMediumπŸ”’#84Sum Root to Leaf NumbersTree DFSMediumπŸ”’#85All Nodes Distance K in Binary TreeGraph BFS/DFSMediumπŸ”’#86Is Graph Bipartite?Graph BFS/DFSMediumπŸ”’#87Keys and RoomsGraph BFS/DFSMediumπŸ”’#88Find the Town JudgeGraph BFS/DFSEasyπŸ”’#89Evaluate DivisionGraph BFS/DFSMediumπŸ”’#90Accounts MergeUnion-findMediumπŸ”’#91Jump Game II1D DPMediumπŸ”’#92Min Cost to Connect All PointsUnion-findMediumπŸ”’#93Swim in Rising WaterShortest pathHardπŸ”’#94Path With Minimum EffortShortest pathMediumπŸ”’#95Fibonacci Number (Recursion β†’ Memo β†’ DP)RecursionEasyπŸ”’#96Letter Case PermutationBacktrackingMediumπŸ”’#97Burst Balloons2D DPHardπŸ”’#98Regular Expression Matching2D DPHardπŸ”’#99Reconstruct ItineraryGraph BFS/DFSHardπŸ”’#100Unique Binary Search Trees1D DPMediumπŸ”’