Python | Multi Pointers | O(26n)
Code\n\nfrom collections import defaultdict\nfrom collections import Counter\nclass Solution:\n    def countCompleteSubstrings(self, word: str, k: int) -> int:\
# Code\n```\nfrom collections import defaultdict\nfrom collections import Counter\nclass Solution:\n    def countCompleteSubstrings(self, word: str, k: int) -> int:\n        idxes = defaultdict(list)\n        for i,c in enumerate(word):\n            idxes[c].append(i)\n        curidx = defaultdict(int)\n        counter = Counter()\n        saturated = set()\n        res = 0\n        prev = \'#\'\n        for i, c in enumerate(word):\n            if abs(ord(prev) - ord(c))>2:\n                saturated = set()\n                counter = Counter()\n                for ch in \'abcdefghijklmnopqrstuvwxyz\':\n                    while curidx[ch] < len(idxes[ch]) and idxes[ch][curidx[ch]] < i:\n                        curidx[ch] += 1\n            counter[c] += 1\n            if counter[c] == k or counter[c] == k+1:\n                saturated.add(c)\n                if counter[c] == k + 1:\n                    curidx[c] += 1\n                    counter[c] -= 1\n                tmplist = []\n                for ch in saturated:\n                    tmplist.append((idxes[ch][curidx[ch]], c))\n                tmplist.sort(reverse = True)\n                cnt = 1\n                for j, ch in tmplist:\n                    if i-j+1 == cnt*k:\n                        res += 1\n                    cnt += 1\n            prev = c\n        return res\n                \n\n                \n                \n\n\n\n        \n```
['Python3']