fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a[5]={2,4,7,1,5};
  7. int b[3]={5,4,2};
  8. unordered_set<int>m;
  9. for(int i=0;i<5;i++){
  10. m.insert(a[i]);
  11. }
  12. for(int i=0;i<3;i++){
  13. if(m.count(b[i])==0){
  14. cout<<"there exist subarray"<<endl;
  15. return 0;
  16. }
  17.  
  18. }
  19. cout<<"there exit the subarray"<<endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
there exit the subarray