title: Why is my method creating an extra list within a list? Leetcode 3Sum question
body: <p>This is a solution for leetcode 3sum problem: <a href="https://leetcode.com/problems/3sum/" rel="nofollow noreferrer">https://leetcode.com/problems/3sum/</a></p>
  <p>I think I have a solution, might be slow but nonetheless a solution. But I cant seem to figure out why I keep getting an extra list. Basically for the <code>input:nums = [-1,0,1,2,-1,-4]</code><br />
  I should get back from my code the output: <code>[[-1,-1,2],[-1,0,1]]</code>.<br />
  But instead I am getting: <code>[[-1, 2, 1], [-1, 1, 0], [-1, 1, 0]]</code>.</p>
  <p>I tried using this to remove the duplicate list, but I think there is some logical error being made to cause this extra list. Here is that code to remove duplicate lists within list, wasn't giving any useful output, just memory location.</p>
  <p><strong>code:</strong></p>
  <pre><code>dup_set = set(map(tuple,a))
  non_dup_set = map(list,dup_set)
  </code></pre>
  <p>Was also thinking I might need a hashmap so that the method knows not to re-use indexes but my understanding of hashmaps is not that good, I just think key-values, but nothing beyond that.</p>
  <p><strong>Here is the full code:</strong></p>
  <pre><code>class Solution:
      def threeSum(self, nums):
          nums.sort()
          l = 0
          r = len(nums) - 1
          final_list = []
          
          while l &lt; r:
              if nums[l] + nums[r] &lt;= 0:
                  print(nums[l+1:r])
                  if (nums[l] + nums[r]) in nums[l+1:r]:
                      final_list.append([nums[l],nums[r],(nums[l]+nums[r])])
                  l+=1
              elif nums[l] + nums[r] &gt;= 0:
                  print(nums[l+1:r])
                  if -(nums[l] + nums[r]) in nums[l+1:r]:
                      final_list.append([nums[l],nums[r],(nums[l]+nums[r])])
                  r-=1
  
          print(final_list)
              
              
  Solution().threeSum([-1,0,1,2,-1,-4])
  </code></pre>
  <p>Output: <code>[[-1, 2, 1], [-1, 1, 0], [-1, 1, 0]]</code></p>
  <p>Desired: <code>[[-1, 2, 1], [-1, 1, 0]]</code></p>
  <p>Please help
  Thank you</p>