you give string s 0indexed you ask perform follow operation s sorted stringfind large index 1 slength si si 1find large index j j slength sk si 1 possible value k range j inclusiveSwap character indice 1 jReverse suffix start index iReturn number operation need string sort since answer large return modulo 109 7 Example 1input s cbaoutput 5explanation the simulation go followsOperation 1 i2 j2 Swap s1 s2 scab reverse suffix start 2 now scaboperation 2 i1 j2 Swap s0 s2 sbac reverse suffix start 1 now sbcaoperation 3 i2 j2 Swap s1 s2 sbac reverse suffix start 2 now sbacoperation 4 i1 j1 Swap s0 s1 sabc reverse suffix start 1 now sacboperation 5 i2 j2 Swap s1 s2 sabc reverse suffix start 2 now sabcexample 2input s aabaaoutput 2explanation the simulation go followsoperation 1 i3 j4 Swap s2 s4 saaaab reverse substring start 3 now saaabaoperation 2 i4 j4 Swap s3 s4 saaaab reverse substring start 4 now saaaab Constraints1 slength 3000s consists lowercase english letter