✔✔Java || HashSet || 2 For Loops || Easy-Understanding
\nclass Solution {\n    public int countDistinct(int[] arr, int k, int p) {\n        Set<String> set = new HashSet<>();\n        for(int i=0;i<arr.length;i++){\
```\nclass Solution {\n    public int countDistinct(int[] arr, int k, int p) {\n        Set<String> set = new HashSet<>();\n        for(int i=0;i<arr.length;i++){\n            int count = 0;\n            \n            StringBuilder sb = new StringBuilder();\n            \n            for(int j=i;j<arr.length;j++){\n                if(arr[j]%p==0)\n                    count++;\n                \n                if(count>k)\n                    break;\n\n /*There is a reason why I have added space in between sb, try to dry run for \n below commented testcase you will get to know*/\n \n                sb.append(arr[j]+" ");\n                set.add(sb.toString());\n            }\n        }\n        return set.size();\n    }\n}\n\n\n/*[19, 198, 1987, 1, 198719, 7, 987, 8, 9, 98719, 8719, 98, 87, 719] */\n\n```
['String', 'Java']