I am using a function to return a vector of integers, but the problem is that if I type return out inside the if statement it gives me an error. If I type it out of for loop the code works. After the if statement works, I need to force the loop to stop and returning the out vector.
vector<int> icecreamParlor(int m, vector<int> arr) {
vector<int> out;
for(int i = 0 ; i < arr.size(); i++){
int x = arr [i];
for(int z = 1 ; z < arr.size(); z++){
if(x + arr[z] == m){
out.push_back(i+1);
out.push_back(z+1);
return out;
}
}
}
}
THis is the error massage
Solution.cpp: In function ‘std::vector<int> icecreamParlor(int, std::vector<int>)’:
Solution.cpp:10:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
for(int i = 0 ; i < arr.size(); i ++){