Amazon Interview Question

Asked me to code DFS