PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Validate a training courses catalog

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of directed graphs, cycle detection, dependency validation, and data consistency in the context of a training course catalog with prerequisites.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Validate a training courses catalog

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a catalog of training courses. Each course has: - a unique `course_id` - a list of prerequisite course IDs `prereqs` (possibly empty) Write a function `isValidCatalog(courses) -> bool` that validates the catalog. A catalog is considered **valid** if: 1. Every prerequisite referenced by a course **exists** in the catalog. 2. The prerequisite relationships contain **no cycles** (a course cannot depend on itself directly or indirectly). Follow-ups (discuss, no need to implement unless asked): - How would you also return a valid course-taking order when it’s valid? - Time and space complexity. - Compare DFS vs BFS approaches for detecting cycles / producing a topological order. Example: - `A: [B, C]`, `B: [C]`, `C: []` -> valid - `A: [B]`, `B: [A]` -> invalid (cycle) - `A: [X]` where `X` not in catalog -> invalid

Quick Answer: This question evaluates understanding of directed graphs, cycle detection, dependency validation, and data consistency in the context of a training course catalog with prerequisites.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Implement Event Filtering and Queue Routing - Amazon (medium)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
Amazon logo
Amazon
Jan 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0
Loading...

You are given a catalog of training courses. Each course has:

  • a unique course_id
  • a list of prerequisite course IDs prereqs (possibly empty)

Write a function isValidCatalog(courses) -> bool that validates the catalog.

A catalog is considered valid if:

  1. Every prerequisite referenced by a course exists in the catalog.
  2. The prerequisite relationships contain no cycles (a course cannot depend on itself directly or indirectly).

Follow-ups (discuss, no need to implement unless asked):

  • How would you also return a valid course-taking order when it’s valid?
  • Time and space complexity.
  • Compare DFS vs BFS approaches for detecting cycles / producing a topological order.

Example:

  • A: [B, C] , B: [C] , C: [] -> valid
  • A: [B] , B: [A] -> invalid (cycle)
  • A: [X] where X not in catalog -> invalid

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.