Python3 ||  7 lines, deque  || T/S: 96% / 53%
Here\'s the plan: \n1. We create d to facilitate changing each character of s to its alpha-index.\n\n2. We create queue to keep track of the number each charact
Here\'s the plan: \n1. We create `d` to facilitate changing each character of `s` to its *alpha-index*.\n\n2. We create `queue` to keep track of the number each character as we perform each transformation.\n3. For each transformation, we use *pop-push* to update the counts.\n4. We return the sum of `queue` as the solution.\n\n```python3 []\nfrom string import ascii_lowercase as alpha\nmod = 1_000_000_007\n\nclass Solution:\n    def lengthAfterTransformations(self, s: str, t: int) -> int:\n\n        d = {ch: i for i, ch in enumerate(alpha)}       # <- 1\n\n        queue = deque([0] * 26)                         # <- 2\n        for ch in s: queue[d[ch]] += 1\n\n        for i in range(t):                              # <- 3\n            queue[0]+= queue[25]\n            queue.appendleft(queue.pop())\n            \n        return sum(queue) %mod                          # <- 4\n```\n``` C++ []\nconst int MOD = 1\'000\'000\'007;\n\nclass Solution {\npublic:\n    int lengthAfterTransformations(string s, int t) {\n\n        vector<int> queue(26, 0);                       // <- 1\n\n        for (char ch : s) {                             // <- 2\n            queue[ch - \'a\']++;  }\n\n        for (int i = 0; i < t; ++i) {                   // <- 3\n            queue[0] += queue[25];\n            queue[0] %= MOD;\n            int last = queue.back();\n            queue.pop_back();\n            queue.insert(queue.begin(), last);}\n        \n        int sum = 0;\n        \n        for (int count : queue) {\n            sum = (sum + count) % MOD; }\n        \n        return sum;                                     // <- 4\n    }\n};\n```\n\n[https://leetcode.com/problems/total-characters-in-string-after-transformations-i/submissions/1435483959/](https://leetcode.com/problems/total-characters-in-string-after-transformations-i/submissions/1435483959/)\n\nI could be wrong, but I think that time complexity is *O*(*N* + *T*) and space complexity is *O*(1), in which *N* ~ `len(nums)` and *T* ~ `t`. (Note that `d` and `queue` are each constant space)
['C++', 'Python3']