Skip to content

[Graph BFS/DFS] Course Schedule II #124

@sudosf

Description

@sudosf

Problem

Given n courses and prerequisites, return a valid ordering of courses to finish all of them. Return empty array if impossible.

References

Difficulty

🟡 Medium

Companies

Amazon, Microsoft, PhonePe

Notes

Language: Java
Topological sort returning the actual order. Kahn's algorithm (BFS with in-degree) naturally produces the order. DFS approach reverses the finish order.

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