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 331–360 of 434 results
Tests multi-source BFS to find an empty cell minimizing total shortest-path distance to all targets on a grid with obstacles.
Auto-gradedbreadth-first-searchgraphsgrid-traversalTests directed graph traversal, Eulerian path construction, and lexicographical ordering with Hierholzer's algorithm.
Auto-gradedgraphsdfseulerian-pathbacktrackingTests ability to traverse a nested schema definition, flatten heterogeneous check results, and enforce a consistent empty-list contract across all node types.
Auto-gradedrecursionschema-validationflatteningTests BFS traversal with directional output reversal per level without corrupting the queue structure.
Auto-gradedbfsbinary-treelevel-orderqueueTests graph modeling of multiplicative relationships and pathfinding to derive transitive ratios between variables.
Auto-gradedgraphbfsunion-findBuild a recursive evaluator for filter expressions with logical operators and field comparisons, testing tree traversal and nested field lookup.
Auto-gradedrecursiontreesdictionariesImplement binary search on a monotone predicate, BFS for state-space and grid shortest paths, and random board generation with adjacency counting.
Model answerbinary-searchbfsshortest-pathgraph-traversalTest whether a breadth-first list representation of a binary tree satisfies strict BST ordering without allowing duplicate values.
Auto-gradedbinary-treebstvalidationTests BFS-based shortest-path reasoning on an unweighted 2D grid with blocked cells and 4-directional movement.
Auto-gradedbfsgraph traversalgridshortest pathBuild a function that classifies propositions as definitely true, definitely false, or undetermined given a set of facts and implication rules.
Model answergraphimplication2-SATDFSTests recursive validation of nested dictionaries against a schema with type and presence requirements.
Auto-gradedrecursionvalidationnested-structuresTests directed graph construction, cycle detection via Kahn's algorithm, and deterministic tie-breaking with a min-heap to produce the lexicographically smallest valid ordering.
Auto-gradedtopological-sortgraphsheaps- Count Landlocked IslandsMedium
Tests connected-component detection in grids with boundary constraints using BFS or DFS traversal.
Auto-gradedbfsdfsconnected-componentsgrid-traversal Tests recursion, dictionary traversal, and string formatting to produce an indented tree structure with box-drawing connectors.
Auto-gradedrecursiontree-traversalstringsformattingTests whether a candidate can use post-order traversal to handle cascading leaf deletions in a binary tree encoded as a level-order list.
Auto-gradedbinary-treepost-order-traversalrecursiontree-serializationTests implicit heap-tree traversal, subtree identification via index arithmetic, and stable compaction without mutating the input array.
Auto-gradedtrees-graphsarraysbfs-dfsTests ability to implement BFS on an undirected unweighted graph stored as an adjacency matrix to find the fewest edges between two nodes.
Auto-gradedgraphsbfsadjacency-matrixTests bipartite graph traversal and BFS to find shortest paths alternating between items and their containing collections.
Auto-gradedgraph-theorybfsbipartite-graphTests ability to detect cycles in a directed graph using DFS-based cycle detection, modelling package dependencies where a cycle makes installation impossible.
Auto-gradedgraphscycle detectiondepth-first searchtopological orderTests binary search on answer combined with multi-source BFS and 2D prefix sums to optimally place one relay node and minimize the maximum Chebyshev coverage distance.
Auto-gradedbinary-searchbfsmatrixprefix-sumsTests BFS/DFS connected-components traversal on a 2D grid to locate distinct filled regions and compute the tightest enclosing rectangle for each.
Auto-gradedbfsdfsconnected-componentsgridTests BFS/Dijkstra on an augmented state space where position must be combined with a key-collection bitmask, and directional arrow tiles enforce constrained traversal.
Auto-gradedbfsdijkstrabitmaskgridNavigate a robot through an unmapped grid with obstacles using only movement and turn commands to locate a target cell.
Model answerdfsbacktrackinggraph-traversalsimulationFind the minimum moves for a Chinese-chess horse to reach a target on a 10×9 grid, accounting for the leg-blocking movement restriction and obstacle squares.
Model answerBFSgraph traversalboard gamesshortest pathTests Kahn's algorithm with a min-heap to produce the lexicographically smallest valid processing order across nodes in a directed dependency graph, or detect a cycle.
Auto-gradedtopological-sortgraphsheapTests backtracking DFS with trie-based pruning to find all words from a large list that can be traced through edge-adjacent, non-repeating cells in a 2-D letter grid.
Auto-gradedbacktrackingtriedfsTests understanding of topological sorting, dependency graph modeling, and cycle detection in directed acyclic graphs.
Auto-gradedtopological-sortgraphsbfscycle-detectionWrite a recursive function that traverses a binary tree to locate the largest integer value, accounting for null pointers and negative-only trees.
Model answerrecursionbinary-treetraversaledge-casesTests BFS/DFS grid traversal by spreading a new color through all 4-directionally connected cells sharing the starting cell's original color.
Auto-gradedbfsgridgraph-traversalTests context hashing, union-find for transitive closure, and precise output formatting to group words that are mutually substitutable in identical four-word windows.
Auto-gradedunion-findhashingstrings