Validate That a Proposed Deploy Order Respects Every Dependency

Last updated: November 29, 2026

Quick Overview

Given a list of services, a list of dependencies [a, b] meaning a must be deployed before b, and a proposed deploy order, return True if the order contains every service exactly once and never deploys a service before one of its dependencies.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of services, a list of dependencies [a, b] meaning a must be deployed before b, and a proposed deploy order, return True if the order contains every service exactly once and never deploys a service before one of its dependencies.

Asked in Meta technical screens as a gentle entry into dependency graphs, framed as a check run by a deploy tool before it pushes a release train. The interviewer is looking for the position-index trick and careful validation of the order itself, not a full topological sort.

What the Interviewer Expects
  • Map each service to its index in the proposed order
  • Check every dependency edge with one comparison
  • Validate that the order is a permutation of the services
  • Explain why a full topological sort is unnecessary here
  • Return the first violating edge when asked for diagnostics
Key Topics to Cover
topological order
hash map
validation
dependency graph
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 report all violations, not just whether one exists?
  • If the order is invalid, how would you produce the closest valid order?
  • How would you verify the order when dependencies are only known transitively?
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
  • Input: services (distinct names), deps as [before, after] pairs, and order.
  • Return True only if order is a permutation of services and for every edge before appears earlier than `a...
High-Level Design

A sequence is a valid topological order of a graph exactly when every edge points forward in it. So I do not need to compute an order, only verify one:

  1. Check order has the same length as `servic...

Submit Your Answer
Markdown supported