No Same Permutations

What logic are we supposed to use here?

The idea is simple you can use recursion here, suppose array numbers are 1,2,3 so apply recursion on 2,3 that is leaving first element, now recursion will give all permutations of subarray ,we assume that now store that answers now add 1 to the result of above recursion at all possible positions but take care of duplicates by checking that elements at current index and next index are not same. So recursion give 2 3 and 3 2 now add 1 to all possible positions.

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.