'commit'
This commit is contained in:
25
TangDou/AcWing/DoublePointer/2816.cpp
Normal file
25
TangDou/AcWing/DoublePointer/2816.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 1e5 + 10;
|
||||
int a[N], b[N];
|
||||
|
||||
int main() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
for (int i = 0; i < n; i++) cin >> a[i];
|
||||
for (int i = 0; i < m; i++) cin >> b[i];
|
||||
|
||||
// 初始化i,j
|
||||
int i = 0, j = 0;
|
||||
while (i < n && j < m) {
|
||||
if (a[i] == b[j]) i++;
|
||||
j++;
|
||||
}
|
||||
// 如果匹配成功
|
||||
if (i == n)
|
||||
puts("Yes");
|
||||
else
|
||||
puts("No");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user