Second question in interview was basic topological sort.
Implement topological_sort(num_nodes, prerequisites) for a directed graph. Each pair [a, b] means b must appear before a; return any valid ordering of nodes 0 through num_nodes - 1, or [] if the graph contains a cycle.
The function signature is topological_sort(num_nodes, prerequisites). Return a list of node IDs.
def topological_sort(num_nodes, prerequisites):