Neural Concept Interview Question

backtracking problem from leet code