Answer: Oracle OA Question 2024 June | Graphs & Topological Sort | on-campus

Answer · Posted Jun 2026

Solution : Course Schedule II — Kahn's Algorithm (BFS) Approach This problem can be modeled as finding a topological sort of a directed acyclic graph (DAG), where courses are nodes and prerequisites are directed edges. We use Kahn's Algorithm (BFS-based) by tracking the in-degree (number of incoming dependency edges) for each node: We first build an adjacency list representation of the graph and compute the in-degrees for all nodes. We place all nodes with an in-degree of 0 (no prerequisites) ...

The full answer & interview discussion are available to premium members.

Log in Create a free account