题目
原题链接:A. Colorful Stones (Simplified Edition)
题意
有s和t两个字串,若相等则在s前进一步,问最终能走几步。
代码
#include<bits/stdc++.h>
using namespace std;
int main() {
string s,t;
cin>>s>>t;
int ans=1;
for(int i=0,j=0;i<t.size();i++){
if(s[j]==t[i]) {ans++;j++;}
}
cout<<ans;
return 0;
}