Python Efficient Solution | Generate Substrings | Easy to Understand
\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        l = set()\n        for i in range(len(nums)):\n            a = 
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        l = set()\n        for i in range(len(nums)):\n            a = 0 \n            x = ""\n            for j in range(i,len(nums)):\n                x+=str(nums[j])+\'-\'\n                if nums[j]%p==0:\n                    a+=1\n                if a>k:\n                    break \n                l.add(x)\n        return len(l)\n```
['Combinatorics', 'Ordered Set', 'Python']