Qualtrics interview question

Problem involving recursion/backtracking