Sorted permutation rank

I have created the function for finding rank of sorted permutation of string. But there is error for large inputs. What is the mistake? https://ide.codingblocks.com/s/108153

Hello, @vrindabansal05,

I have modified your code:

I have added the necessary comments to explain your mistake.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

It is still not giving the correct answer.

Can you send the entire code? or the link of this question?

https://www.interviewbit.com/problems/sorted-permutation-rank/

Now, it’s working correctly,

1 Like