getting tle .
ide: https://ide.codingblocks.com/s/194400
No same permutation
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]);
}
https://ide.codingblocks.com/s/197397 Accepted code. There was no need to undo swaps while backtracking.