All Permutations of a string when corresponding characters are not in the same place
- by r20rock
I need all possible permutations of a given string such that no character should remain at the same place as in the input string. Eg. : for input "ask" Output: all possible permutaions like "ksa", "kas"... such that 'a' is not in the 1st position , 's' is not in the 2nd positions and so on... in any permutation. I only need the count of such possible permutations I can do this by generating all permutations and filtering them but I need a very efficient way of doing this. All characters in the string are "UNIQUE" Preferred language C++.