TC 1, showing WA. Where is the fault??
Topological sort using DFS
5
A
B
C
D
E
5
C A
D A
B D
E B
E C
Correct output : E B C D A
Your Output: E C B D A
You are not maintaining the order between element which are not related. You will see priority of element before printing.(Use ordered map and sets)
You may refer to this code for seeing how map and set.
@sayanwinz If this resolves your doubt mark it resolved.