You are given a s. In one operation, you can perform the following steps:
Find the largest index i such that s.length and s[i - 1] > s[i].
Find the largest index j such that s.length and s[i - 1] > s[j].
Swap the characters s[i - 1] and s[j].
Reverse the suffix of s starting at index i.
Return the number of operations needed to make s sorted in ascending order. Since the answer may be very large, return it modulo
Constraints:
s.length
s consists only of lowercase English letters.
You are given a s. In one operation, you can perform the following steps:
Find the largest index i such that s.length and s[i - 1] > s[i].
Find the largest index j such that s.length and s[i - 1] > s[j].
Swap the characters s[i - 1] and s[j].
Reverse the suffix of s starting at index i.
Return the number of operations needed to make s sorted in ascending order. Since the answer may be very large, return it modulo
Constraints:
s.length
s consists only of lowercase English letters.