where am i going wrong in not passing all test cases

# hashing Techinique

class Solution:
    def threeSum(self, nums: List[int]) -> List[List[int]]:
        x = 0
        n = len(nums)
        ans = set()
        for i in range(0,n - 1):
            s = set()
            for j in range(i + 1, n):
                x = -(nums[i] + nums[j]) # x = x - y
                if x in s:
                    ans.add((x,nums[i],nums[j]))
                else:
                    s.add((nums[j]))                      
        return list(ans)

        
# [-1,0,1,2,-1,-4]
# x = -(-1 + 0)
# x = 1
# s = 1

# i =-1 , j =1
# x = -(-1+1)
# x = 0
# s = 1,0

# i = -1 , j = 2
# x = - (-1 + 2)
# x = -1
# s = 1,0,-1

# [-1,-1,2] = 0

# [3,0,-2,-1,1,2]
# x = -3
# s = 3

# i = 3, j = -2
# x = -(3 + -2)
# x = -1
# s = 3, -1

# x = -(3 + -1)
# x = -2
# s = 3, -1, -2
# ans = [3, -1, -2]

# x = - (3 + 1)
# x = -4
# s = 3, -1, -2, -4

# x = -(3+2)
# x = -5
# s = 3, -1, -2, -4, -5






Comments (0)