fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <bits/stdc++.h>
  4. #include<vector>
  5.  
  6. int main() {
  7. // your code goes here
  8.  
  9. vector<int>a={1,8,5,4,3,2,1};
  10. vector<int>b={1,5,1};
  11. int n=a.size();
  12. int m=b.size();
  13. int count=0;
  14. int i=0,j=0;
  15. while(i<n && j<m)
  16. {
  17. if(a[i]==b[j])
  18. {
  19. count++;
  20. i++;
  21. j++;
  22. }
  23. else
  24. {
  25. i++;
  26. }
  27. }
  28.  
  29. if(count==m)
  30. {
  31. cout<<"yes";
  32. }
  33. else
  34. {
  35. cout<<"no";
  36. }
  37. //cout<<count;
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
yes