Topological sorting:
1) Select any one among vertices having no incoming edge
2) Put the node into the solution & Remove the node and its outgoing edges from the graph
4) Repeat the above steps until no nodes remain
You need to InDegree[n] array to save and update all the vetex InDegree, and stack to store all the vetex which indegree is 0.