acwing2816. 判断子序列

link

code

#include<bits/stdc++.h>

using namespace std;
const int N = 100010;
int a[N],b[N];
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= m; i++) cin >> b[i];
	int i = 1, j = 1;
	while(i <= n && j <= m){
		if(a[i] == b[j]) i++, j++;
		else j++;
	}
	if(i == n + 1)
	cout <<"Yes";
	else
	cout << "No";
	return 0;
}
posted @ 2023-04-07 19:29  天黑星更亮  阅读(14)  评论(0)    收藏  举报