Domanda di colloquio di ByteDance

Permutation question from leetcode (BackTracking)