Lexicographic Rank of a String
Posted: 13 Jul, 2021
Ninja got holiday homework from his English teacher. His teacher gave him a string and told him to find the rank of the string if the string is sorted in lexicographical order.
Ninja is very new into programming, he didn’t know how to solve this question but he has to solve this question as this question has a very heavy weightage among all the questions given in holiday homework.
Ninja knows that you are a very good programmer who has practiced a lot of questions. Help Ninja!.
There will only be distinct characters in the given string.
First line contains an integer ‘T’ denoting the number of test cases. First and the only line of the test case contains a string ‘S’.
Output contains an integer ‘X’ denoting the Lexicographic Permutation Rank of the given string.
You don’t need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 25 1 <= |S| <= 20 ‘a’ <= S[i] <= ‘z’ Time Limit: 1 sec.
Iruka And Marks
Posted: 5 Jul, 2022
Best time to buy and sell stock
Posted: 2 Sep, 2022
Best time to buy and sell stock II
Posted: 5 Sep, 2022
Posted: 21 Oct, 2022
Find The Single Element
Posted: 30 Oct, 2022