Naive code, using DFS + stack + reverse vector