AND Digital interview question

Recursion based question and backtracking traversing