How to Solve
This problem is solved by the following steps.
- find out index that each letter appears int the last position
- have the indexes calculating at step 1 in a array
- sort the arrays created at step2 4 check the string in the adjustment range and find out minimum value
find out index that each letter appears int the last position
this index guarantees that the letter appears the last position. This means that the letter have to be taken by the range to the index. So, I can find out the minimum value in the range.