NO SAME PERMUTATIONS

How should I approach this question without a Set or Map?

added comments
shared the standard codefor this question