Order Underwriting Checks Given Dependency Constraints

Last updated: November 29, 2026

Quick Overview

An underwriting pipeline has named checks and a list of (before, after) dependencies. Return the lexicographically smallest order that respects every dependency, or report the checks involved if the dependencies contain a cycle.

Upstart
Coding & Algorithms
Software Engineer
Upstart
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


An underwriting pipeline has named checks and a list of (before, after) dependencies. Return the lexicographically smallest order that respects every dependency, or report the checks involved if the dependencies contain a cycle.

Upstart's decisioning flow runs identity verification, fraud screening, income verification, model scoring and pricing in a dependency order, and engineers add new checks often. The interviewer checks Kahn's algorithm, cycle detection, and the extra twist of deterministic tie-breaking.

What the Interviewer Expects
  • Build an adjacency list and in-degree map
  • Use Kahn's algorithm with a min-heap for lexicographic order
  • Detect cycles when not every node is emitted
  • Produce a useful error message naming stuck checks
Key Topics to Cover
topological sort
Kahn's algorithm
heaps
cycle detection
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Which checks can run in parallel, and how many stages do you need at minimum?
  • How would you validate a new dependency at config time without rebuilding everything?
  • If each check has a latency, what is the critical path?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Every check appears in checks; dependencies reference only known checks. Among valid orders, choose the lexicographically smallest list. A cycle raises an error that lists the checks that never reac...

High-Level Design

Kahn's algorithm repeatedly removes a node with in-degree zero. Replacing the usual queue with a min-heap means that whenever several checks are ready, the alphabetically smallest goes first, which yi...


Submit Your Answer
Markdown supported