454. 4Sum II

class Solution(object):
    def fourSumCount(self, A, B, C, D):
        """
        :type A: List[int]
        :type B: List[int]
        :type C: List[int]
        :type D: List[int]
        :rtype: int
        """
        AB=collections.Counter(a+b for a in A for b in B)
        return sum(AB[-c-d] for c in C for d in D)

你可能感兴趣的:(454. 4Sum II)