My python3 solution

  • 0
    from collections import defaultdict
    class Solution(object):
        def findPairs(self, nums, k):
            :type nums: List[int]
            :type k: int
            :rtype: int
            if not nums:
                return 0
            if k < 0:
                return 0
            help = defaultdict(list)
            res = set()
            for item in nums:
                if item in help:
                    for each in help[item]:
                        maybe = (item, each)
                        if maybe not in res and maybe[::-1] not in res:
            return len(res)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.