Walmart Interview Question

Question related to DFS and 1 related to array