Java Solution | Sliding Window + Trie | Runtime: 41 ms, faster than 98.46%
\nclass Solution {\n    private static class Node {\n\t\tprivate int val;\n\t\tprivate boolean isEnd;\n\t\tprivate Node[] children;\n\n\t\tpublic Node(int val) 
```\nclass Solution {\n    private static class Node {\n\t\tprivate int val;\n\t\tprivate boolean isEnd;\n\t\tprivate Node[] children;\n\n\t\tpublic Node(int val) {\n\t\t\tthis.val = val;\n\t\t\tthis.isEnd = false;\n\t\t\tthis.children = new Node[201];\n\t\t}\n\t}\n\n\tprivate int totalCount = 0;\n\tprivate Node root = new Node(0);\n\t\n\tprivate void insert(int[] nums, int left, int right) {\n\t\tNode curr = this.root;\n\t\tfor (int i = left; i <= right; i++) {\n\t\t\tint childIdx = nums[i];\n\t\t\tif (curr.children[childIdx] == null) {\n\t\t\t\tcurr.children[childIdx] = new Node(childIdx);\n\t\t\t}\n\t\t\tcurr = curr.children[childIdx];\n\t\t\tif (!curr.isEnd) {\n\t\t\t\ttotalCount++;\n\t\t\t\tcurr.isEnd = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int countDistinct(int[] nums, int k, int p) {\n\t\tint count = 0;\n\t\tint n = nums.length;\n\t\tint left = 0;\n\t\tint right = 0;\n\t\twhile (left < n) {\n\t\t\twhile (right < n) {\n\t\t\t\tif (nums[right] % p == 0) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tif (count == k + 1) {\n\t\t\t\t\tcount--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tright++;\n\t\t\t}\n\t\t\tinsert(nums, left, right - 1);\n\t\t\tif (nums[left] % p == 0) {\n\t\t\t\tcount--;\n\t\t\t}\n\t\t\tleft++;\n\t\t}\n\t\treturn totalCount;\n\t}\n}\n```\nSome Other Problems Using Trie Data Structure \n[1268 : Search Suggestions System](https://leetcode.com/problems/search-suggestions-system/discuss/2638534/java-solution-using-trie-runtime-37-ms-beats-7219)\n[1233 : Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/discuss/2638522/java-solution-using-trie-runtime-43-ms-beats-9605)\n[648\t: Replace Words](https://leetcode.com/problems/replace-words/discuss/2638625/java-solution-using-trie-runtime-14-ms-beats-962219)\n[820\t: Short Encoding of Words](https://leetcode.com/problems/short-encoding-of-words/discuss/2639021/java-solution-using-trie)\n[208\t: Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree/discuss/2638657/simple-java-solution)\n[386\t: Lexicographical Numbers](https://leetcode.com/problems/lexicographical-numbers/discuss/2639107/java-solution-using-trie)\n[1023 : Camelcase Matching](https://leetcode.com/problems/camelcase-matching/discuss/2639736/java-solution-using-trie)\n[677\t: Map Sum Pairs](https://leetcode.com/problems/map-sum-pairs/discuss/2639994/java-solution-using-trie-and-hashmap)\n[676\t: Implement Magic Dictionary](https://leetcode.com/problems/implement-magic-dictionary/discuss/2640276/java-solution-using-trie)\n[421\t: Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/discuss/2643276/java-trie-approach-add-number-and-check-its-max-xor-on-fly-tc-on-and-sc-on)\n[792\t: Number of Matching Subsequences](https://leetcode.com/problems/number-of-matching-subsequences/discuss/2643489/java-solutions-two-approach-1-using-trie-2-hashmap)\n[720\t: Longest Word in Dictionary](https://leetcode.com/problems/longest-word-in-dictionary/discuss/2643586/java-solution-using-trie-dfs)\n[2261 : K Divisible Elements Subarrays](https://leetcode.com/problems/k-divisible-elements-subarrays/discuss/2643761/java-solution-sliding-window-trie-runtime-41-ms-faster-than-9846)\n[139\t: Word Break](https://leetcode.com/problems/word-break/discuss/2643915/java-solutions-two-approach-1-using-trie-bfs-2-dp)\n[211\t: Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure/discuss/2643839/java-solution-using-trie-dfs)\n[1948 : Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system/discuss/2646138/java-solution-using-trie-with-postorder-and-inorder-dfs-traversal)\n[1032 : Stream of Characters](https://leetcode.com/problems/stream-of-characters/discuss/2646970/java-solution-using-trie)\n[212. Word Search II](https://leetcode.com/problems/word-search-ii/discuss/2779677/Java-Solution-or-Using-Trie)
['Tree', 'Trie', 'Sliding Window', 'Java']