```
vector<vector<int> > threeSum(vector<int> &num) {
vector < vector < int > > result;
int size = num.size();
if(size < 3){
return result;
}
sort(num.begin(), num.end());
int temp;
vector < int > tempResult;
for(int i = 0; i < size - 2; i ++){
if(i != 0 && num[i] == num[i - 1]){
continue;
}
if(num[i] > 0){
break;
}
int j = i + 1, k = size - 1;
while(j < k){
if(- num[i] - num[j] < num[j]){
break;
}
temp = num[i] + num[j] + num[k];
if(temp == 0){
tempResult = {num[i], num[j], num[k]};
result.push_back(tempResult);
}else{
if(temp > 0){
do{
k --;
}while(num[k] == num[k + 1]);
}else{
do{
j ++;
}while(num[j] == num[j - 1]);
}
}
}
}
return result;
}
```