Pergunta de entrevista da empresa ByteDance

Permutation question from leetcode (BackTracking)