Getting an error trying to insert a vector into vector of vectors

I was doing a problem earliar. we were given an array and were required to find the pairs whose sum is equal to an integer. Now this is my solution:

vector<vector<int,int> > pairSum(vector<int> &arr, int s){
  sort(arr.begin(),arr.end());
  vector<vector<int,int> > pairs;
  int *p=&arr[0];
  int *q=&arr[arr.size()-1];
  while(p!=q){
   if(*p+*q>s){
       q--;
   }
   else if(*p+*q<s){
       p++;
   }
   else if(*p+*q==s){
       vector<int> temp;
       int a=*p,b=*q;
       temp.push_back(a);
       temp.push_back(b);
       pairs.push_back(temp);
       if(p!=p+1 && q!=q-1){
       p++;
       q--;}
       else if(p=p+1){
           p++;
       }
       else if(q=q-1){
           q--;
       }
   }
  }
  return pairs;
}

But I keep getting the error

‘int’ is not a class, struct, or union type|

and it opens a header file named alloc_traits,h and shows this error
This is the error im getting

  • i just realised there is a error at the end of the function in the way im comparing the values , i fixed it but im still getting the same error.

    – 

  • 1

    Please post the complete error verbatim – all text lines.

    – 

  • How do i post that?

    – 

  • 2

    vector<vector<int,int> > pairs;. What is vector<int, int> supposed to do?

    – 




  • 1

    else if(p=p+1), else if(q=q-1) – are you sure this is what you wanted ? It’s better to separate assignment from condition checking.

    – 




Leave a Comment