Python3 Precompute Table & Deque | 64ms | Beats 99%
Code\npython3 []\nclass Solution:\n    MOD = 10 ** 9 + 7\n\n    @classmethod\n    @cache\n    def cache(cls):\n        cache = [1] * 26\n        for i in range(
# Code\n```python3 []\nclass Solution:\n    MOD = 10 ** 9 + 7\n\n    @classmethod\n    @cache\n    def cache(cls):\n        cache = [1] * 26\n        for i in range(26, 100027):\n            cache.append((cache[i - 26] + cache[i - 25]) % cls.MOD)\n        return cache\n\n    def lengthAfterTransformations(self, s: str, t: int) -> int:\n        count = Counter(s)\n        return sum((self.cache()[i + t] * count[chr(ord("a") + i)]) for i in range(26)) % self.MOD\n\n    def lengthAfterTransformationsDeque(self, s: str, t: int) -> int:\n        count = Counter(s)\n        de = deque(count[chr(ord("a") + i)] for i in range(26))\n\n        for _ in range(t):\n            de[0] += de[-1]\n            de.rotate()\n\n        return sum(de) % self.MOD\n```
['Python3']