当前位置:网站首页>The longest child sequence of the 2019 Blue Bridge Cup

The longest child sequence of the 2019 Blue Bridge Cup

2022-06-23 00:54:00 Stephen_ Curry___

Topic link :

link : The longest subsequence .

Ideas

As soon as you see the longest subsequence, you can think of using the double pointer algorithm to solve it , The subject is very simple , Just simulate it .

C++ Code

#include<bits/stdc++.h>
using namespace std;
int main(){
    
    string s1, s2;
    cin >> s1 >> s2;
    int len = 0;
    for(int i = 0, j = 0; i < s1.size(); i++){
    
        if(s1[i] == s2[j]){
    
            j++;
            len++;
        }
    }
    cout << len;
    return 0;
}  
原网站

版权声明
本文为[Stephen_ Curry___]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221425299563.html