practice a little every day — you've got this ♡
Trees & Graphs Interview Problems
Practice 5971 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.
- 5971
- Problems
- 2211
- Auto-graded
- 15
- Topics
- 272
- Added today
Showing 301–330 of 349 results
- Trees & GraphsMediumAuto-gradedCount Separate Land Regions in a Grid
Tests flood-fill traversal to identify connected components in a 2D grid with four-directional adjacency.
Trees & Graphsgraphsbfsdfsconnected-components - Trees & GraphsMediumAuto-gradedCollect Binary Tree Node Values in Left-Root-Right Order
Tests binary tree traversal using an explicit stack to visit nodes in left-root-right sequence from a level-order serialized input.
Trees & Graphsbinary-treetraversalstackdeserialization - Trees & GraphsMediumAuto-gradedFilter Users by Active Connection Threshold
Tests graph maintenance with dynamic edge insertion and deletion, proper handling of duplicates and missing edges, and final degree counting.
Trees & Graphsgraphshash-tablesimulation - Trees & GraphsMediumAuto-gradedMinimum-Length Root-to-Leaf Path with Target Sum
Tests tree traversal with state tracking to identify the shortest valid path satisfying a sum condition.
Trees & Graphsbinary-treedfspath-finding - Trees & GraphsMediumAuto-gradedSignal Propagation Time to All Destinations
Tests understanding of multi-source BFS to compute the longest shortest path from any source to all required destinations on a grid with obstacles.
Trees & Graphsbreadth-first-searchgridmulti-source-bfsshortest-path - Trees & GraphsMediumAuto-gradedLowest Shared Ancestor in Organization Hierarchy
Finding the deepest node that lies on the upward path to the root for all given employees in a tree structure.
Trees & Graphstreelowest-common-ancestordepth-first-searchbreadth-first-search - Trees & GraphsHardAuto-gradedFeature Deployment with Integrity Checks and Dependency Ordering
Verify configuration integrity using polynomial hashing, detect dependency cycles with DFS, and produce a lexicographically-ordered topological deployment sequence.
Trees & Graphsgraph-traversaltopological-sorthashingcycle-detection - Trees & GraphsHardAuto-gradedBuild Frequency-Based Binary Codec
Tests ability to construct a deterministic frequency tree with tie-breaking, generate prefix-free binary codes, and encode/decode strings.
Trees & Graphstreesheapsgreedybit-manipulation - Trees & GraphsMediumAuto-gradedCompute Subtree Sums from Parent Array
Tests bottom-up aggregation in trees represented as parent arrays, requiring iterative traversal to avoid recursion limits on deep trees.
Trees & Graphstreespost-orderaggregationiterative - Trees & GraphsHardAuto-gradedMinimum Cost Route with Limited Layovers
Tests understanding of constrained shortest-path algorithms on directed weighted graphs with edge-count restrictions.
Trees & Graphsgraphsshortest-pathbellman-fordconstraints - Trees & GraphsMediumAuto-gradedMinimum Steps in Word Ladder
Tests BFS on an implicit graph with efficient neighbor generation using wildcard pattern indexing.
Trees & Graphsbfsgraphstringhashing - Trees & GraphsMediumAuto-gradedCompute Minimum Distances to Multiple Destinations
Tests understanding of single-source shortest path algorithms on weighted directed graphs with positive edge weights.
Trees & Graphsshortest-pathdijkstragraph-traversalpriority-queue - Trees & GraphsMediumAuto-gradedIsland Detection and Letter Selection Counting
Tests graph traversal for connected components in a binary grid and combinatorial counting with multiset constraints.
Trees & Graphsgraph-traversalbfsconnected-componentscombinatorics - Trees & GraphsMediumAuto-gradedMaximum Independent Set Weight on a Tree
Tests tree DP by computing the maximum total weight of a node subset where no two chosen nodes share an edge (weighted tree independent set).
Trees & Graphstreesdynamic programminggraph traversal - Trees & GraphsMediumAuto-gradedCell Formula Evaluator with Cycle Detection
Build a mini spreadsheet engine that evaluates formulas, detects circular dependencies, and handles dynamic updates.
Trees & Graphsgraphsdfsrecursionmemoization - Trees & GraphsMediumAuto-gradedCount Separated Land Regions in a Binary Matrix
Tests graph traversal skills by identifying connected components in a 2D grid using BFS or DFS.
Trees & Graphsgraph-traversalbfsdfsconnected-components - Trees & GraphsMediumAuto-gradedLargest Connected Land Region
Measures understanding of graph traversal on a grid to compute connected-component sizes using four-directional adjacency.
Trees & Graphsgraphsdfsconnected-componentsgrid-traversal - Trees & GraphsMediumAuto-gradedGrid Infection Spread with Time Limit
Tests BFS-based grid simulation with simultaneous state updates, barrier cells, and handling extremely large iteration counts efficiently.
Trees & Graphsbfsgridsimulationqueue - Trees & GraphsEasyAuto-gradedTree Height Levels: Bottom-Up Node Grouping
Compute each node's height in a rooted tree and group nodes by height, testing tree traversal and bottom-up computation.
Trees & Graphstreesbfsheightbottom-up - Trees & GraphsHardAuto-gradedCalculate Grid Infection Time
Tests breadth-first search from multiple sources to model time-based propagation in a grid with obstacles and unreachable regions.
Trees & Graphsbfsgridmulti-sourcegraph-traversal - Trees & GraphsMediumAuto-gradedIdentify the Nearest Shared Ancestor of Two Tree Nodes
Tests tree reconstruction and ancestor tracking to locate the closest common parent of two given values in a binary tree.
Trees & Graphsbinary-treetree-traversalancestor-search - Trees & GraphsMediumAuto-gradedMinimax Solver for 3×3 Tic-Tac-Toe with Optimal Move Selection
Implement a recursive game-tree solver that finds the outcome under optimal play and identifies a winning or drawing move for the current player.
Trees & Graphsrecursionbacktrackinggame-theoryminimax - Trees & GraphsMediumAuto-gradedIdentify Tree Roots and Trace Ancestor Paths
Tests graph traversal, parent-pointer navigation, and root identification in tree-like structures represented as parent references.
Trees & Graphsgraphstreeshash-mapspath-finding - Trees & GraphsMediumAuto-gradedMaximum Path Bonus in a Weighted Tree
Tests tree DP (rerooting) by finding the node from which the maximum sum of weighted edges can be collected along any single root-to-leaf path in a tree.
Trees & Graphstreesdynamic-programmingtree-dpdepth-first-search - Trees & GraphsMediumAuto-gradedSubtree Sum Replacement in Level-Order Arrays
Tests post-order traversal, heap indexing in complete binary trees, and efficient bottom-up aggregation without recursion.
Trees & Graphsbinary-treespost-order-traversalcomplete-binary-treeaggregation - Trees & GraphsHardAuto-gradedEarliest Moment a Social Network Becomes Fully Connected
Tests offline dynamic graph connectivity using a segment-tree-over-time with a rollback-capable union-find to handle both edge insertions and deletions.
Trees & Graphsunion-findsegment-treedynamic-connectivity - Trees & GraphsMediumAuto-gradedSchedule Tasks With Resource Unlock Dependencies
Tests ability to apply topological ordering to determine a valid execution sequence of tasks where each task may unlock resources required by others.
Trees & Graphsgraphstopological sortDAGKahn's algorithm - Trees & GraphsMediumAuto-gradedAggregate User Permissions Through Account Ancestry
Tests hierarchical graph traversal and efficient permission accumulation using ancestor path lookup and set operations.
Trees & Graphsgraphstreesbfscaching - Trees & GraphsMediumAuto-gradedCalculate Cumulative Task Weights in a Dependency Graph
Tests graph traversal and dynamic programming on DAGs to compute propagated weight contributions through dependency chains.
Trees & Graphsgraphsdagtopological-sortdynamic-programming - Trees & GraphsMediumAuto-gradedRank Build Targets by Dependency Order
Tests whether a candidate can produce a valid topological ordering of a build-dependency DAG and apply a precise tie-break rule when multiple orderings exist.
Trees & Graphsgraphstopological sortBFSKahn's algorithm