title: runtime error: pointer index expression with base 0x000000000000 overflowed to 0xffffffffffffffe8
body: <p>The question was to find all unique triplets which give sum=0 in an array and return a vector with a list of all those unique triplets.
  This was my class definition:</p>
  <pre><code>class Solution {
  public:
      vector&lt;vector&lt;int&gt;&gt; threeSum(vector&lt;int&gt;&amp; nums) {
          vector&lt;vector&lt;int&gt;&gt;ans;
          for(int i=0; i&lt;nums.size(); i++)
          {
              for(int j=i+1; j&lt;nums.size(); j++)
              {
                  for(int k=j+1; k&lt;nums.size(); k++)
                  {
                      if(nums[i]+nums[j]+nums[k]==0)
                      {  
                         ans.push_back( {nums[i], nums[j], nums[k]} );
                      }
                  }
              }
          }
          set&lt;int&gt; s(ans.begin(),ans.end());
          ans.assign(s.begin(),s.end());
          return ans;
      }
  };
  </code></pre>
  <p>And now I'm getting the above mentioned error. Can anyone please help me with a simple explanation of what I did wrong and suggest an alternative?</p>