Use Set
\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        Set<String> set=new HashSet<>();\n        for(int i=0;i<nums.length;i++){\
```\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        Set<String> set=new HashSet<>();\n        for(int i=0;i<nums.length;i++){\n            StringBuilder sb=new StringBuilder();\n            int count=0;\n            for(int j=i;j<nums.length;j++){\n                if(nums[j]%p==0) count++;\n                if(count>k) break;\n                sb.append(nums[j]+"*");\n                set.add(sb.toString());\n            \n                \n            }\n        }\n        return set.size();\n    }\n}\n```
[]