-->
当前位置:首页 > 题库

PROGRAMMING:Letter Porter

Luz5年前 (2021-05-10)题库375
Winter vacation passed too fast, Mr. Xiao found that he had not used his brain, so he wanted to mend his rusty head, so he designed an intelligence game "letter Porter". The rules of the game are as follows: give you two words, the letters in the two words are the same, and carry the first word, One operation means to move a letter in a word (see the prompt for details). Ask how many operations are required to convert the first word into the second word at least.
###Input format:
There are several groups of input, each line has two words (each word length is not more than 100, and only contains lowercase letters, and the letter composition of the two words is the same, but the relative position is different), separated by spaces.
###Output format:
For each group of data output, the minimum number of operations from the first word to the second word.
###Input example:
Here is a set of inputs. For example:
```in
ecabd abcde
aba aab
```
###Output example:
The corresponding output is given here. For example:
```out
two
one
```
Tips
ecabd abcde
Handling method:
ecabd -> cabde -> abcde
The first operation carries the letter E to the last
The second operation moves the C between B and D
So there are two operations here. In fact, the minimum operation of these two words is also two







answer:If there is no answer, please comment