题目描述
双指针,理解题目思路
样例
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int[] a = new int[n];
int[] b = new int[m];
for(int i = 0 ; i < n ; i ++ ) a[i] = scan.nextInt();
for(int i = 0 ; i < m ; i ++ ) b[i] = scan.nextInt();
int i = 0 , j = 0 ;
while(i < n && j < m ){
//有相同才i++ 否则j++
if(a[i] == b[j]) i ++ ;
j ++ ;
}
if(i == n) System.out.println("Yes");
else System.out.println("No");
}
}