Can you please tell how to go about solving this problem?
Not Understanding approach
Hey @omkarkhodwe
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 .`
What if it is 1,3,2? How will we ensure that answer comes lexicographically?
you can store all the permutations in a vector and then sort it to get answer lexicographically.