c++解题
class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums)
{
vector<vector<int>> result;
sort(nums.begin(),nums.end());
for(int i=0;i<nums.size();i++)
{
if(i>0&&nums[i]==nums[i-1])continue;
int mid=i+1;
int last=nums.size()-1;
while(mid<last)
{
int sum=nums[i]+nums[mid]+nums[last];
if(sum>0)
last--;
else if(sum<0)
mid++;
else
{
result.push_back(vector<int>{nums[i],nums[mid],nums[last]});
mid++;
while(mid<last&&nums[mid]==nums[mid-1])
mid++;
}
}
}
return result;
}
};
vector<vector<int> > A;
vector<vector<int> > A;
vector<int> B;
B.push_back(0);
B.push_back(1);
B.push_back(2);
A.push_back(B);
B.clear();
B.push_back(3);
B.push_back(4);
A.push_back(B);
vector<vector<int> > A;
for(int i=0;i<2;++i)
A[0].push_back(0);
A[0].push_back(1);
A[0].push_back(2);
A[1].push_back(3);
A[1].push_back(4);