Pregunta de entrevista de ByteDance

Permutation question from leetcode (BackTracking)