Sponsored
Use these hints if you're stuck. Try solving on your own first.
Note that the operations given describe getting the previous permutation of s
To solve this problem you need to solve every suffix separately
Solve with full IDE support and test cases