不理解为什么,期待输出0,代码输出为3
求hack
附代码:
#include<bits/stdc++.h>
using namespace std;
string s,t;
bool f;
int lt=-1,cnt,ans;
int main(){
cin>>s>>t;
for(int i=0;i<t.size();i++){
f=0;
for(int j=lt+1; !f && j<s.size();j++)
if( t[i]==s[j] ){
f=1; cnt++; lt=j;
}
ans = max(ans,cnt);
if( !f )
cnt=0;
}
cout<<ans;
}