2261. K Divisible Elements Subarrays
On This Page
class Solution:
def countDistinct(self, nums: List[int], k: int, p: int) -> int:
n = len(nums)
s = set()
for i in range(n):
cnt = 0
t = ""
for x in nums[i:]:
cnt += x % p == 0
if cnt > k:
break
t += str(x) + ","
s.add(t)
return len(s)