Preview:
vector<vector<int> > Solution::threeSum(vector<int> &A) {
    vector<int>v1;
    set<vector<int>>s;
    int n=A.size();
    sort(A.begin(),A.end());
    for(int i=0;i<n-2;i++)
    {
        int j=i+1;
        int k=n-1;
        while(j<k)
        {  
            long long sum = 0LL+A[i]+A[j]+A[k];
            if(sum==0)
            {
            v1.push_back(A[i]);
            v1.push_back(A[j]);
            v1.push_back(A[k]);
            s.insert(v1);
            v1.clear();
            }
            if(A[i]+A[j]+A[k]<0) j++;
            else k--; 
        }
        
    }
    vector<vector<int>>v2(s.begin(),s.end());
    return v2;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter