AND Digital Interview Question

Recursion based question and backtracking traversing