practice a little every day — you've got this ♡
Trees & Graphs Interview Problems
Practice 5972 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.
- 5972
- Problems
- 2212
- Auto-graded
- 15
- Topics
- 273
- Added today
Showing 331–360 of 434 results
- Trees & GraphsMediumAuto-gradedOptimal Empty Cell with Minimum Path Distance Sum
Tests multi-source BFS to find an empty cell minimizing total shortest-path distance to all targets on a grid with obstacles.
Trees & Graphsbreadth-first-searchgraphsgrid-traversal - Trees & GraphsMediumAuto-gradedBuild Travel Route from Airline Tickets
Tests directed graph traversal, Eulerian path construction, and lexicographical ordering with Hierholzer's algorithm.
Trees & Graphsgraphsdfseulerian-pathbacktracking - Trees & GraphsMediumAuto-gradedFlat Error Collection from a Recursive Schema Validator
Tests ability to traverse a nested schema definition, flatten heterogeneous check results, and enforce a consistent empty-list contract across all node types.
Trees & Graphsrecursionschema-validationflattening - Trees & GraphsMediumAuto-gradedAlternating Direction Level Order Tree Traversal
Tests BFS traversal with directional output reversal per level without corrupting the queue structure.
Trees & Graphsbfsbinary-treelevel-orderqueue - Trees & GraphsHardAuto-gradedCompute Division Chains from Given Ratios
Tests graph modeling of multiplicative relationships and pathfinding to derive transitive ratios between variables.
Trees & Graphsgraphbfsunion-find - Trees & GraphsMediumAuto-gradedMatch Documents Against Filter Expressions
Build a recursive evaluator for filter expressions with logical operators and field comparisons, testing tree traversal and nested field lookup.
Trees & Graphsrecursiontreesdictionaries - Trees & GraphsMediumModel answerSearch and Shortest-Path Algorithms
Implement binary search on a monotone predicate, BFS for state-space and grid shortest paths, and random board generation with adjacency counting.
Trees & Graphsbinary-searchbfsshortest-pathgraph-traversal - Trees & GraphsMediumAuto-gradedVerify BST Property on a Level-Order Encoded Tree
Test whether a breadth-first list representation of a binary tree satisfies strict BST ordering without allowing duplicate values.
Trees & Graphsbinary-treebstvalidation - Trees & GraphsHardAuto-gradedMinimum Moves Across an Obstacle Grid
Tests BFS-based shortest-path reasoning on an unweighted 2D grid with blocked cells and 4-directional movement.
Trees & Graphsbfsgraph traversalgridshortest path - Trees & GraphsHardModel answerLogical Inference Engine: TRUE, FALSE, or Undetermined
Build a function that classifies propositions as definitely true, definitely false, or undetermined given a set of facts and implication rules.
Trees & Graphsgraphimplication2-SATDFS - Trees & GraphsMediumAuto-gradedRecursive Schema Validation
Tests recursive validation of nested dictionaries against a schema with type and presence requirements.
Trees & Graphsrecursionvalidationnested-structures - Trees & GraphsMediumAuto-gradedLexicographic Topological Sort of a Task Graph
Tests directed graph construction, cycle detection via Kahn's algorithm, and deterministic tie-breaking with a min-heap to produce the lexicographically smallest valid ordering.
Trees & Graphstopological-sortgraphsheaps - Trees & GraphsMediumAuto-gradedCount Landlocked Islands
Tests connected-component detection in grids with boundary constraints using BFS or DFS traversal.
Trees & Graphsbfsdfsconnected-componentsgrid-traversal - Trees & GraphsMediumAuto-gradedBuild a Visual Directory Tree from Nested Dictionary
Tests recursion, dictionary traversal, and string formatting to produce an indented tree structure with box-drawing connectors.
Trees & Graphsrecursiontree-traversalstringsformatting - Trees & GraphsHardAuto-gradedPrune All Leaves Matching a Value, Cascading Upward
Tests whether a candidate can use post-order traversal to handle cascading leaf deletions in a binary tree encoded as a level-order list.
Trees & Graphsbinary-treepost-order-traversalrecursiontree-serialization - Trees & GraphsMediumAuto-gradedSubtree Erasure in an Array-Backed Binary Tree
Tests implicit heap-tree traversal, subtree identification via index arithmetic, and stable compaction without mutating the input array.
Trees & Graphstrees-graphsarraysbfs-dfs - Trees & GraphsMediumAuto-gradedMinimum Hops Between Nodes in a Matrix-Represented Graph
Tests ability to implement BFS on an undirected unweighted graph stored as an adjacency matrix to find the fewest edges between two nodes.
Trees & Graphsgraphsbfsadjacency-matrix - Trees & GraphsMediumAuto-gradedMinimum Collections to Link Two Items
Tests bipartite graph traversal and BFS to find shortest paths alternating between items and their containing collections.
Trees & Graphsgraph-theorybfsbipartite-graph - Trees & GraphsMediumAuto-gradedDetect Cycles in a Package Dependency Graph
Tests ability to detect cycles in a directed graph using DFS-based cycle detection, modelling package dependencies where a cycle makes installation impossible.
Trees & Graphsgraphscycle detectiondepth-first searchtopological order - Trees & GraphsHardAuto-gradedReduce Worst-Case Coverage Gap with One New Relay Node
Tests 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.
Trees & Graphsbinary-searchbfsmatrixprefix-sums - Trees & GraphsMediumAuto-gradedAxis-Aligned Bounding Boxes of Grid Regions
Tests BFS/DFS connected-components traversal on a 2D grid to locate distinct filled regions and compute the tightest enclosing rectangle for each.
Trees & Graphsbfsdfsconnected-componentsgrid - Trees & GraphsMediumAuto-gradedShortest Path Through a Grid With Keys and One-Way Portals
Tests BFS/Dijkstra on an augmented state space where position must be combined with a key-collection bitmask, and directional arrow tiles enforce constrained traversal.
Trees & Graphsbfsdijkstrabitmaskgrid - Trees & GraphsMediumModel answerRobot Grid Exploration with Limited Sensing API
Navigate a robot through an unmapped grid with obstacles using only movement and turn commands to locate a target cell.
Trees & Graphsdfsbacktrackinggraph-traversalsimulation - Trees & GraphsHardModel answerShortest Path for a Hobbled Xiangqi Horse on a 10×9 Board
Find 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.
Trees & GraphsBFSgraph traversalboard gamesshortest path - Trees & GraphsMediumAuto-gradedLexicographically Smallest Schedule or Detect a Deadlock
Tests 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.
Trees & Graphstopological-sortgraphsheap - Trees & GraphsMediumAuto-gradedSpell Words Along Connected Paths in a Letter Grid
Tests 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.
Trees & Graphsbacktrackingtriedfs - Trees & GraphsMediumAuto-gradedFind Valid Completion Sequence for Dependent Tasks
Tests understanding of topological sorting, dependency graph modeling, and cycle detection in directed acyclic graphs.
Trees & Graphstopological-sortgraphsbfscycle-detection - Trees & GraphsMediumModel answerRecursive Maximum Search in an Arbitrary Binary Tree
Write a recursive function that traverses a binary tree to locate the largest integer value, accounting for null pointers and negative-only trees.
Trees & Graphsrecursionbinary-treetraversaledge-cases - Trees & GraphsEasyAuto-gradedPaint Bucket: Recolor a 4-Connected Region in a Grid
Tests BFS/DFS grid traversal by spreading a new color through all 4-directionally connected cells sharing the starting cell's original color.
Trees & Graphsbfsgridgraph-traversal - Trees & GraphsMediumAuto-gradedCluster Interchangeable Words by Surrounding Context
Tests context hashing, union-find for transitive closure, and precise output formatting to group words that are mutually substitutable in identical four-word windows.
Trees & Graphsunion-findhashingstrings