Pregunta de entrevista de Flatiron Health

Asked a recursive backtracking style question.