454-4Sum-Ii

Sat 17 May 2025

https://leetcode.com/problems/4sum-ii

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def fourSumCount(self, A: List[int], B: List[int], C: List[int], D: List[int]) -> int:
    count = Counter(a + b for a in A for b in B)

    return sum(count[-c - d] for c in C for d in D)
new Solution().fourSumCount()

Score: 5

Category: leetcode