Find nth permutation of a string containing duplicate characters efficiently.

Hi,
I want to find nth permutation of a string containing duplicate characters.
So far, I know that If the string does not contain any duplicate characters answer can be found using Factoradic number system as explained here

But for string containing duplicate characters, I am stuck.

This question is being asked in Amazon hiring challenge on Hackerearth so please refrain from discussing this question.

2 Likes

This is a question on LightOj and solution is here https://github.com/pin3da/Programming-contest/blob/master/solved/lightoj/1060%20-%20nth%20Permutation/solution.cc

But i don’t understand the solution.I will try to understand and will explain to you if i got it.

Now that the challenge is over,please share the answer.

1 Like