Find the index of a given permutation in the sorted list of the permutations of a given string

后端 未结 6 650
轻奢々
轻奢々 2020-11-29 04:29

We\'re given a string and a permutation of the string.

For example, an input string sandeep and a permutation psdenae.

Find the pos

6条回答
  •  隐瞒了意图╮
    2020-11-29 05:22

    My approach to the problem is sort the given permutation. Number of swappings of the characters in the string will give us the position of the pemutation in the sorted list of permutations.

提交回复
热议问题