Cadence Design Systems interview question

write an iterative version of DFS