No same permutation

getting tle .
ide: https://ide.codingblocks.com/s/194400

You don’t have to use SET or MAP. It is clearly mentioned in the question. It will give TLE. You have to write the code in such a way that it does not produce the duplicate permutations.
Here have a look at the code, you need yo to add another conditon.
if(i==idx or a[i]!=a[idx]){
swap(a[i],a[idx]);
solve(a,idx+1);
swap(a[i],a[idx]);
}

still getting wrong answer in test cases . ide: https://ide.codingblocks.com/s/194624

https://ide.codingblocks.com/s/197397 Accepted code. There was no need to undo swaps while backtracking.

@abhinandankainth1999 Can you explain why we are not backtracking?