Problem : [https://www.codechef.com/DEC18A/problems/DLDAG/][1]

Can someone please let me know what is wrong in my

```
[2]. Basically, what I did was, first I deleted all those vertices which don't have an edge to any other vertices (labeled as the vector **freed** in the code). I maintained two vector arrays, one for the children and other for the parent of a vertex. Initially, for the already free vertices, I removed them from their parents' adjacency list and checked if any node got free of all its children nodes, if yes, push it into the stack, make it the next to be deleted and repeat the same process till all vertices are deleted. I grouped the 1st two elements of the stack (if there were >=2 elements at a time in it) to be deleted together (because since they are in the stack, that implies they don't have any children nodes), or left a solitary 1 node to be deleted alone(in case only 1 element was left in the stack).
I tried with several possible DAGs, solved the sequence for them with hand and matched with the output of my code. Everything was right, but I still got WA. If someone could kindly find any case which I might have missed out, it would be really thankful.
Edit : [@vijju123][3] can you please close this question. Reason: Question answered, need to learn Topological sort :p
[1]: https://www.codechef.com/DEC18A/problems/DLDAG/
[2]: https://www.codechef.com/viewsolution/21984454
[3]: https://discuss.codechef.com/users/187411/vijju123
```