PAT T1015 Letter-moving Gam
双下标法找最长公共子序列(不能删除字符)
#include<bits/stdc++.h> using namespace std; const int maxn=1014; string s; string t; int main () { cin>>s>>t; int maxLength=0; int st,ed; for (int i=0;i<s.length();i++) { st=i; ed=0; while (st<s.length()&&ed<s.length()) { if (s[ed]==t[st]) st++; ed++; } maxLength=max(maxLength,st-i); } printf ("%d",s.length()-maxLength); return 0; }