Simple python3 solution | Simulation with recursion
Complexity\n- Time complexity: O(n + t)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(t)\n Add your space complexity here, e.g. O(n) \n\n
# Complexity\n- Time complexity: $$O(n + t)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(t)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\nwhere `n = s.length <= 10^5` and `t <= 10^5`\n\n# Code\n```python3 []\nclass Solution:\n    def lengthAfterTransformations(self, s: str, t: int) -> int:\n        modulo = 1_000_000_007\n\n        @cache\n        def rec(char, t):\n            shift = 26 - (ord(char) - 97)\n            t -= shift\n            if t < 0:\n                return 1\n            return (rec(\'a\', t) + rec(\'b\', t)) % modulo\n        \n        return sum(\n            rec(char, t) * cnt\n            for char, cnt in Counter(s).items()\n        ) % modulo\n\n```
['Recursion', 'Memoization', 'Simulation', 'Python3']