Pergunta de entrevista da empresa Snap

typical leetcode backtracking question with time and space complexity.