Turing Interview Question

A DSA Challenge like backtracking