Longest subsequence
[Problem description]
We say that a string S contains a string T means that T is a subsequence of S, that is, several characters can be extracted from the string S, and they are combined into a new string and T in the original order exactly the same.
Given two character strings S and T, how many characters should be modified at least so that S can contain T?
[Input format]
Enter two lines, one character string per line. The string in the first line is s, and the string in the second line is T. Both strings are non-empty and only contain uppercase English letters.
[Output format]
Output an integer to indicate the answer.
[Sample input]
ABCDEABCD
AABZ
[Sample output]
3
Idea: The
idea is very simple, traverse the string S from the beginning to the end, and meet the same k++ as t[p], and the answer is k at the end of the run
s=input()
t=input()
k=0
for i in range(len(s)):
if s[i]==t[k]:
k+=1
if k==len(t):
break
print(k)