Getting tle, whart is a faster way of computing this?

the answer is submitted so not posting a link again it passes all test except one , also how to do without map/set.

hello @shibangi
a)
u have sorted the input array so no need to perform backtracking.
b)
to avoid duplicates ,perform swap only if a[i] !=a[j]

check this->

that’s very cool :slight_smile: thanks alot !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.