Domanda di colloquio di IBM

Coding questions from hackerank. two questions based on permutations