Topological sort doubt

please check the code .
Is it correct?

Hey @divesh2000
it looks correct to me.