KatInterview

practice a little every day — you've got this ♡

Trees & Graphs Interview Problems

Practice 5967 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.

5967
Problems
2210
Auto-graded
15
Topics
272
Added today

Showing 421–434 of 434 results

  • Trees & GraphsMediumAuto-graded
    Detect a Cycle in a Directed Course Prerequisite Graph

    Tests whether you can model dependency constraints as a directed graph and use topological sort to detect cycles that make all tasks impossible to complete.

    Trees & Graphstopological-sortgraphcycle-detection
  • Trees & GraphsMediumModel answer
    Finding Profitable Exchange Cycles with Transaction Fees

    Given exchange rates between currencies and a per-cycle transaction cost, determine if any sequence of trades can yield a profit.

    Trees & Graphsgraph-algorithmsbellman-fordnegative-cyclelogarithms
  • Trees & GraphsHardAuto-graded
    Combine Tree Structures with Ordered Name Matching

    Tests recursive tree traversal with order-sensitive child pairing by name occurrence and careful handling of unmatched nodes.

    Trees & Graphsrecursiontree-traversalhash-table
  • Trees & GraphsMediumAuto-graded
    Connected Land Regions in a Character Matrix

    Tests graph traversal and connected-component identification on a 2D grid using flood-fill techniques.

    Trees & Graphsgraph-traversaldfsconnected-componentsgrid
  • Trees & GraphsMediumAuto-graded
    Detect Circular Dependencies in a Build System

    Tests cycle detection in a directed graph by determining which packages in a build dependency graph are part of a circular dependency chain.

    Trees & Graphsgraphscycle detectionDFStopological sort
  • Trees & GraphsMediumAuto-graded
    Minimum Build Phases for a Software Dependency Graph

    Tests whether a candidate can apply topological ordering (Kahn's algorithm / BFS layer-by-layer) to schedule tasks into the fewest sequential build phases.

    Trees & Graphsgraphstopological sortBFSDAG
  • Trees & GraphsMediumAuto-graded
    Schedule Dependent Tasks with Priority and Tag Exclusion

    Tests Kahn's algorithm with deterministic tie-breaking, urgency-based heap ordering, cycle detection with path reporting, and transparent skipping of tag-excluded tasks.

    Trees & Graphstopological-sortheapgraphs
  • Trees & GraphsMediumAuto-graded
    Sum of Decimal Paths in a Binary Tree

    Tests depth-first (or breadth-first) traversal of a binary tree while tracking the accumulated digit value along each root-to-leaf path.

    Trees & Graphsbinary-treebfsdfs
  • Trees & GraphsMediumAuto-graded
    Recover Build Order From Incremental Patch Dependencies

    Tests whether candidates can apply topological sort (Kahn's algorithm or DFS) to determine a valid linear build order from a dependency graph of software patches.

    Trees & Graphsgraphstopological sortBFSKahn's algorithm
  • Trees & GraphsHardAuto-graded
    Minimum Batches to Complete All Courses with Prerequisites

    Tests topological ordering (Kahn's algorithm / BFS layering) to schedule dependent courses into the fewest sequential batches where each batch runs in parallel.

    Trees & Graphsgraphstopological-sortBFS
  • Trees & GraphsEasyAuto-graded
    Maximum Sum of Independent Nodes in a Tree

    Tests tree DP by finding the maximum sum of node values when no two selected nodes may be adjacent (parent-child) in a rooted tree.

    Trees & Graphstreedynamic programmingrecursion
  • Trees & GraphsMediumAuto-graded
    Minimum Steps to Collect All Treasure on a Grid

    Tests BFS shortest-path reasoning on a grid by finding the minimum steps to collect all treasure chests from a starting position, visiting each chest at least once.

    Trees & GraphsgraphsBFSgridshortest path
  • Trees & GraphsHardAuto-graded
    Fastest Delivery Route with Fuel Stop Limit

    Tests the ability to apply Dijkstra's algorithm augmented with a constraint dimension (fuel stops used) to find the minimum-time path in a weighted graph.

    Trees & Graphsgraphsdijkstrashortest pathdynamic programming
  • Trees & GraphsHardAuto-graded
    Shortest Evacuation Route Through a Burning Building

    Tests BFS shortest-path reasoning on a grid with time-dependent obstacles, requiring candidates to track fire spread and find the minimum escape steps simultaneously.

    Trees & Graphsbfsgridshortest pathmulti-source bfs