title: 3SUM (finding all unique triplets in a list that equal 0)
body: <p>I am working on the 3SUM problem (taken from leetcode), which takes a list as input and finds all unique triplets in the lists such that a+b+c=0. I am not really sure what my code is doing wrong, but it currently returns an empty list for this list [-1, 0, 1, 2, -1, -4], so it is not recognizing any triplets that sum to 0. I would appreciate any suggestions or improved code.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>result = []
  nums.sort()
  l = 0
  r=len(nums)-1
  for i in range(len(nums)-2):
      while (l &lt; r):
          sum = nums[i] + nums[l] + nums[r]
          if (sum &lt; 0):
              l = l + 1
          if (sum &gt; 0):
              r = r - 1
          if (sum == 0): 
              result.append([nums[i],nums[l],nums[r]])
  print(result)
  </code></pre>