How to approach?

how to even approach this problem

@chemant077 hey,you can use recursion here,suppose array numbers are 1,2,3 so apply recusrsion 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 23 and 32 now add 1 to all possible positions.Hope you get it .Feel free to ask any doubt :slight_smile:

this code is not covering all possible ones can you help me with it please

please reply am waiting

???please reply sir

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.

Hey @chemant077
There’s some problem in the logic, try to figure it out by dry running on the sample test case given, and tell if you’re not able to find the problem still.

cant able to find it maam :frowning:

?? please help me not solved

@rishabhmahajan546 hey you have use erase function for vector which is giving problem,take array instead and pass index as parameter in recursion.

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.

@chemant077 hey you have use erase function for vector which is giving problem,take array instead and pass index as parameter in recursion.