Toptal Interview Question

some recursion backtracking algorithm