Domanda di colloquio di Bloomberg

algorithm question about tree backtracking