Topic
Trees & Graphs interview problems
Traversals, shortest paths, topological order and union-find. 434 original problems, each with hidden test cases you can run in the browser.
25 easy362 medium47 hard
Showing 391–420 of 434 results
Tests understanding of constrained shortest-path algorithms on directed weighted graphs with edge-count restrictions.
Auto-gradedgraphsshortest-pathbellman-fordconstraintsTests BFS on an implicit graph with efficient neighbor generation using wildcard pattern indexing.
Auto-gradedbfsgraphstringhashingTests understanding of single-source shortest path algorithms on weighted directed graphs with positive edge weights.
Auto-gradedshortest-pathdijkstragraph-traversalpriority-queueTests graph traversal for connected components in a binary grid and combinatorial counting with multiset constraints.
Auto-gradedgraph-traversalbfsconnected-componentscombinatoricsTests tree DP by computing the maximum total weight of a node subset where no two chosen nodes share an edge (weighted tree independent set).
Auto-gradedtreesdynamic programminggraph traversalBuild a mini spreadsheet engine that evaluates formulas, detects circular dependencies, and handles dynamic updates.
Auto-gradedgraphsdfsrecursionmemoizationTests graph traversal skills by identifying connected components in a 2D grid using BFS or DFS.
Auto-gradedgraph-traversalbfsdfsconnected-componentsMeasures understanding of graph traversal on a grid to compute connected-component sizes using four-directional adjacency.
Auto-gradedgraphsdfsconnected-componentsgrid-traversalTests BFS-based grid simulation with simultaneous state updates, barrier cells, and handling extremely large iteration counts efficiently.
Auto-gradedbfsgridsimulationqueueCompute each node's height in a rooted tree and group nodes by height, testing tree traversal and bottom-up computation.
Auto-gradedtreesbfsheightbottom-upTests breadth-first search from multiple sources to model time-based propagation in a grid with obstacles and unreachable regions.
Auto-gradedbfsgridmulti-sourcegraph-traversalTests tree reconstruction and ancestor tracking to locate the closest common parent of two given values in a binary tree.
Auto-gradedbinary-treetree-traversalancestor-searchImplement a recursive game-tree solver that finds the outcome under optimal play and identifies a winning or drawing move for the current player.
Auto-gradedrecursionbacktrackinggame-theoryminimaxTests graph traversal, parent-pointer navigation, and root identification in tree-like structures represented as parent references.
Auto-gradedgraphstreeshash-mapspath-findingTests 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.
Auto-gradedtreesdynamic-programmingtree-dpdepth-first-searchTests post-order traversal, heap indexing in complete binary trees, and efficient bottom-up aggregation without recursion.
Auto-gradedbinary-treespost-order-traversalcomplete-binary-treeaggregationTests offline dynamic graph connectivity using a segment-tree-over-time with a rollback-capable union-find to handle both edge insertions and deletions.
Auto-gradedunion-findsegment-treedynamic-connectivityTests ability to apply topological ordering to determine a valid execution sequence of tasks where each task may unlock resources required by others.
Auto-gradedgraphstopological sortDAGKahn's algorithmTests hierarchical graph traversal and efficient permission accumulation using ancestor path lookup and set operations.
Auto-gradedgraphstreesbfscachingTests graph traversal and dynamic programming on DAGs to compute propagated weight contributions through dependency chains.
Auto-gradedgraphsdagtopological-sortdynamic-programmingTests 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.
Auto-gradedgraphstopological sortBFSKahn's algorithmTests the ability to extend Dijkstra's algorithm with a constrained resource (fuel), requiring candidates to track both position and remaining fuel as state.
Auto-gradedgraphsdijkstrashortest pathdynamic programmingDetermine the path between two nodes in a Fibonacci-style binary tree using only their preorder indices, without building the tree in memory.
Model answerbinary-treesrecursionfibonaccitree-traversalTests union-find (disjoint set union) to group transmission lines into connected components and answer queries about grid connectivity.
Auto-gradedunion-findgraphsconnected-componentsTests multi-source BFS to find the time until a grid-based propagation process completes or determine impossibility.
Auto-gradedbreadth-first-searchgridmulti-source-bfsTests graph traversal with edge reversal to find all nodes reachable through reversed dependency edges, handling cycles correctly.
Auto-gradedgraph-traversalbfsdirected-graphcycle-detectionTests whether a candidate can produce a valid topological ordering of task dependencies while breaking ties by smallest task ID for determinism.
Auto-gradedgraphstopological sortBFSKahn's algorithmWrite a crawler that visits all pages reachable from a start URL, staying within the same domain, avoiding cycles and duplicate fetches.
Model answergraph-traversalbfsdfsurl-parsingTests 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.
Auto-gradedtreesdynamic programmingdepth-first searchParse Git diffs and a CSV ownership map to identify which contributor owns the most modified files in a branch comparison.
Model answergitfile-iocsvaggregation