Order Nightly Payout Batch Jobs With Dependency Checks

Last updated: November 29, 2026

Quick Overview

Given the list of nightly settlement jobs and dependency pairs (before, after), return a valid run order that picks the alphabetically smallest ready job at each step, plus the list of jobs that can never run because of a cycle.

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

0

0

0 solved


Given the list of nightly settlement jobs and dependency pairs (before, after), return a valid run order that picks the alphabetically smallest ready job at each step, plus the list of jobs that can never run because of a cycle.

Settlement at PayPal runs as a chain of batch jobs (FX rate snapshot, ledger close, payout file generation, reconciliation reports). This topological sort question checks Kahn's algorithm, deterministic tie-breaking with a heap, and graceful reporting of cycles instead of crashing.

What the Interviewer Expects
  • Build in-degree counts and adjacency lists
  • Use Kahn's algorithm with a min-heap for deterministic order
  • Report jobs blocked by cycles rather than returning nothing useful
  • Validate unknown job names in dependencies
  • Give O((V + E) log V) complexity
Key Topics to Cover
topological sort
Kahn's algorithm
cycle detection
heaps
job scheduling
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 run independent jobs in parallel and compute the minimum total wall-clock time given durations?
  • How would you print the actual cycle for an on-call engineer?
  • What happens when one job fails mid-night; which downstream jobs should be skipped?
  • How would you incrementally add a dependency without recomputing everything?
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: jobs (unique names) and deps where (a, b) means a must finish before b starts. Output a tuple (order, blocked): order is a valid execution order using the smallest available name at ea...

High-Level Design

Kahn's algorithm: compute in-degree, start with all zero in-degree jobs, repeatedly pop one, append it to the order and decrement its children. A min-heap instead of a queue gives the alphabetical tie...


Submit Your Answer
Markdown supported

Related Questions