Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Topological build order for services

Python data engineering interview problem. Difficulty: advanced. Pattern: Graphs. About 20 minutes. Part of the Pro drill bank.

Services must build in an order that respects dependencies: a library before the app that imports it. Produce a valid topological order.

Return a topological build order for a service dependency map.

Requirements

  • A service appears only after the services it depends on.
  • If a cycle exists, follow the tests (empty list vs error).

Constraints

  • deps: adjacency map.
  • Isolated services can appear anywhere relative to unrelated chains.
  • Multiple valid orders may exist; pick one the tests accept.

Examples

Input: build_order({'app': ['lib'], 'lib': []}) Output: ['lib', 'app'] This input follows the stated rules and produces this output.

Topics: lakebench, python, graphs.

More Python interview questions · All interview problems · Learn data engineering

advanced

Topological build order for services

Interview-style drill: Given service dependencies, return a valid build order that respects every dependency.

Return a topological build order for a service dependency map.