practice a little every day — you've got this ♡
Trees & Graphs Interview Problems
Practice 5969 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.
- 5969
- Problems
- 2211
- Auto-graded
- 15
- Topics
- 273
- Added today
Showing 391–420 of 434 results
- 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 - Trees & GraphsHardAuto-gradedFastest Delivery Route with Fuel Station Stops
Tests the ability to extend Dijkstra's algorithm with a constrained resource (fuel), requiring candidates to track both position and remaining fuel as state.
Trees & Graphsgraphsdijkstrashortest pathdynamic programming - Trees & GraphsHardModel answerNavigate Between Nodes in a Recursively Defined Binary Tree
Determine the path between two nodes in a Fibonacci-style binary tree using only their preorder indices, without building the tree in memory.
Trees & Graphsbinary-treesrecursionfibonaccitree-traversal - Trees & GraphsMediumAuto-gradedIdentify Connected Power Grid Regions
Tests union-find (disjoint set union) to group transmission lines into connected components and answer queries about grid connectivity.
Trees & Graphsunion-findgraphsconnected-components - Trees & GraphsMediumAuto-gradedGreenhouse Disease Spread Timer
Tests multi-source BFS to find the time until a grid-based propagation process completes or determine impossibility.
Trees & Graphsbreadth-first-searchgridmulti-source-bfs - Trees & GraphsMediumAuto-gradedFind All Downstream Dependents in a Dependency Graph
Tests graph traversal with edge reversal to find all nodes reachable through reversed dependency edges, handling cycles correctly.
Trees & Graphsgraph-traversalbfsdirected-graphcycle-detection - Trees & GraphsMediumAuto-gradedFind Build Order With Optional Priorities
Tests whether a candidate can produce a valid topological ordering of task dependencies while breaking ties by smallest task ID for determinism.
Trees & Graphsgraphstopological sortBFSKahn's algorithm - Trees & GraphsMediumModel answerBuild a Same-Domain Web Page Crawler
Write a crawler that visits all pages reachable from a start URL, staying within the same domain, avoiding cycles and duplicate fetches.
Trees & Graphsgraph-traversalbfsdfsurl-parsing - Trees & GraphsMediumAuto-gradedMaximum Path Gain in a Weighted Tree
Tests tree DP on a weighted tree to find the maximum sum of node values along any root-to-leaf path, using depth-first traversal and subproblem combination.
Trees & Graphstreesdynamic programmingdepth-first search - Trees & GraphsMediumModel answerBuild a File Owner Aggregator for Code Review Assignment
Parse Git diffs and a CSV ownership map to identify which contributor owns the most modified files in a branch comparison.
Trees & Graphsgitfile-iocsvaggregation