Horje
determining whether a array is a subsequence of another array Code Example
determining whether a array is a subsequence of another array
 #include<bits/stdc++.h>
using namespace std;
 
bool issub(int a[],int b[],int n,int m){
  
  int j=0;
  for(int i=0;i<n && j!=m;i++){
    if(a[i]==b[j]) 
    {
      j++;
    }
  }
 
  bool x=(j==m)?1:0;
  return x;
 
}
 
int main(){
   int n,m;
   cin>>n>>m;
  int a[n],b[m];
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  for(int i=0;i<m;i++){
      cin>>b[i];
  }
  if(issub(a,b,n,m)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
 
  return 0;
}




Cpp

Related
call of overloaded ‘swap(int&, int&)’ is ambiguous Code Example call of overloaded ‘swap(int&, int&)’ is ambiguous Code Example
online c++ to c converter Code Example online c++ to c converter Code Example
cmath sqrt Code Example cmath sqrt Code Example
convert hex to decimal arduino Code Example convert hex to decimal arduino Code Example
c++ watch a variable Code Example c++ watch a variable Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12