Medium Accuracy: 33.83%
Submissions: 1127 Points: 4
Given a string, find the rank of the string amongst its permutations sorted lexicographically.
Return 0 if the characters are repeated in the string.
S = "abc"Output:
1Explanation:The order permutations with letters
'a', 'c', and 'b' :
S = "acb"Output:
You don't need to read input or print anything. Your task is to complete the function findRank() which takes the string S as input parameter and returns the rank of the string amongst its permutations. This function returns 0 if the characters are repeated in the string.
Expected Time Complexity: O(|S|*26) Expected Auxiliary Space: O(|S|) Note: |S| represents the length of string S.