Order Nightly Statement Batch Jobs With Dependency Checks

Last updated: November 29, 2026

Quick Overview

Given a set of nightly batch job names and dependency pairs (a must finish before b), return a valid run order, choosing the alphabetically smallest ready job whenever there is a tie, or report the jobs caught in a dependency cycle.

Capital One
Coding & Algorithms
Data Engineer
Capital One
November 29, 2026
Data Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a set of nightly batch job names and dependency pairs (a must finish before b), return a valid run order, choosing the alphabetically smallest ready job whenever there is a tie, or report the jobs caught in a dependency cycle.

Card statement generation at Capital One runs as a chain of batch steps such as posting transactions, accruing interest, assessing fees and rendering statements. Interviewers use this to see whether you know Kahn's algorithm, can make the output deterministic, and can produce a useful error when the configuration has a cycle.

What the Interviewer Expects
  • Build in-degree counts and an adjacency list
  • Use a min-heap of ready jobs for deterministic ordering
  • Detect cycles by comparing processed count to total jobs
  • Report which jobs are stuck, not just that a cycle exists
  • Validate that dependencies only reference known jobs
Key Topics to Cover
Topological sort
Kahn's algorithm
Min-heap
Cycle detection
Batch orchestration
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
  • How would you group jobs into parallel stages so independent jobs run at the same time?
  • Given each job's duration, what is the earliest finish time of the whole batch?
  • How do you resume after a failure without rerunning jobs that already succeeded?
  • How would you print the exact cycle path for the error message?
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
  • Inputs: job names and (before, after) pairs.
  • Output: one ordering where every dependency is respected. Ties are broken alphabetically so reruns produce the same schedule, which matters for audit...
High-Level Design

Kahn's algorithm: compute in-degrees, seed a min-heap with every zero in-degree job, then repeatedly pop the smallest, append it, and decrement its children. A child whose in-degree reaches zero becom...


Submit Your Answer
Markdown supported