Blue Flame Labs Interview Question

Backtracking coding question to solve.