Microsoft Interview Question

Array question based on simple maths DFS graph question