Skip to content

[Graph BFS/DFS] Course Schedule #123

@sudosf

Description

@sudosf

Problem

There are n courses. Given prerequisites as pairs [a, b] meaning b must be taken before a, determine if it is possible to finish all courses (i.e. no cycle exists).

References

Difficulty

🟡 Medium

Companies

Amazon, Google, Goldman Sachs

Notes

Language: Java
Topological sort / cycle detection in directed graph. BFS (Kahn's algorithm using in-degree) or DFS with three-state coloring (unvisited/visiting/visited).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bfsBreadth-first searchdfsDepth-first searchgraphGraph problemsmediumMedium difficulty

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions