title: What is the flaw in my solution for 3Sum?
body: <p>I'm trying to solve <a href="https://leetcode.com/problems/3sum" rel="nofollow noreferrer">3Sum</a> on Leetcode and my code is as follows.</p>
  <pre><code>class Solution:
  def threeSum(self, nums: List[int]) -&gt; List[List[int]]:
      ans = {}
  
      # iterate over each num, setting -num as target
      for index, target in enumerate(nums)
          target = -target
          nums.pop(index)
          ht = {}
          
          for num in nums: 
              # when a match is found, sort it and insert as a tuple to get rid of duplicates in hash table
              if num in ht: 
                  ans[tuple(sorted([-target, num, target - num]))] = None
              
              else:
                  ht[target-num] = num
          
      return list(ans.keys())
  </code></pre>
  <p>This works for 247/311 cases, and I can't seem to figure out why not all. Any help on pointing out flaws in my logic would be appreciated! Thanks in advance!</p>
  <p>Test case as requested:</p>
  <p>Input</p>
  <blockquote>
  <p>[34,55,79,28,46,33,2,48,31,-3,84,71,52,-3,93,15,21,-43,57,-6,86,56,94,74,83,-14,28,-66,46,-49,62,-11,43,65,77,12,47,61,26,1,13,29,55,-82,76,26,15,-29,36,-29,10,-70,69,17,49]</p>
  </blockquote>
  <p>My output</p>
  <blockquote>
  <p>[[-49,15,34],[-82,34,48],[-70,34,36],[-43,-3,46],[-82,36,46],[-14,2,12],[-49,2,47],[-3,1,2],[-43,12,31],[-70,-14,84],[-49,-3,52],[-82,-11,93],[-49,21,28],[-82,21,61],[-70,21,49],[-43,-14,57],[-70,13,57],[-43,15,28],[-29,1,28],[-29,-14,43],[-66,-11,77],[-82,26,56],[-43,17,26],[-14,1,13],[-49,13,36],[-82,13,69],[-49,-6,55],[-70,15,55],[-70,-6,76],[-43,10,33],[-66,10,56],[-11,1,10],[-66,-3,69],[-70,1,69],[-43,-6,49],[-82,33,49],[-66,17,49]]</p>
  </blockquote>
  <p>Expected output</p>
  <blockquote>
  <p>[[-82,-11,93],[-82,13,69],[-82,17,65],[-82,21,61],[-82,26,56],[-82,33,49],[-82,34,48],[-82,36,46],[-70,-14,84],[-70,-6,76],[-70,1,69],[-70,13,57],[-70,15,55],[-70,21,49],[-70,34,36],[-66,-11,77],[-66,-3,69],[-66,1,65],[-66,10,56],[-66,17,49],[-49,-6,55],[-49,-3,52],[-49,1,48],[-49,2,47],[-49,13,36],[-49,15,34],[-49,21,28],[-43,-14,57],[-43,-6,49],[-43,-3,46],[-43,10,33],[-43,12,31],[-43,15,28],[-43,17,26],[-29,-14,43],[-29,1,28],[-29,12,17],[-14,-3,17],[-14,1,13],[-14,2,12],[-11,-6,17],[-11,1,10],[-3,1,2]]</p>
  </blockquote>
  <p>Ran a script to get the diff of</p>
  <blockquote>
  <p>[-82, 17, 65], [-66, 1, 65], [-49, 1, 48], [-29, 12, 17], [-14, -3, 17], [-11, -6, 17]</p>
  </blockquote>