Skip to main content
All Questions

Determine which services are affected when some services go offline.

Unlock detailed company stats for this questionUpgrade

Amazon has many services, and there are dependency relationships between them. If some of these services are taken offline, determine which other services will be affected.

Clarifications: the input is always valid (no dependency cycles), and the input format is up to the candidate. I defined it as a hash map where the key is the service name and the value is the list of services that depend on it. The problem is essentially topological sorting.

Approach: compute the in-degree of each service; add all services with in-degree 0 to a queue; start a set of affected services with the services taken offline; process the queue: pop a service, and if it is in the affected set, add its dependents to the affected set; decrease the in-degree of the dependents and enqueue any that reach 0; when the queue is empty, return the affected set.

Format · Amazon SDE intern second round.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.