This is a classic "collision-detection" problem that involves calculating a difference from the final state.
Let M be the number of items in a string. Kasumi Sort can be achieved by taking the minimum number of empty slots for every possible concatenation from an index to by the runtime complexity of
Kasumi just likes messing things up. You'd better NOT to reproduce this sorting algorithm at your neighbor supermarket.