2799. Count Complete Subarrays in an Array - LeetCode
class Solution:
def countCompleteSubarrays(self, nums: list[int]) -> int:
amt, D, result, i = {}, len(set(nums)), 0, 0
for num in nums:
amt[num] = amt.get(num, 0) + 1
while len(amt) == D:
amt[nums[i]] -= 1
if amt[nums[i]] == 0:
del amt[nums[i]]
i += 1
result += i
return result