freq concept.
IntuitionApproachComplexity

Time complexity:
O(t*26).


Space complexity:
O(52) ~ O(1).

Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(t*26).

- Space complexity:
O(52) ~ O(1).

# Code
```cpp []
class Solution {
public:
    int lengthAfterTransformations(string s, int t) {
        int mod = (int)(1e9 + 7);
        int n = s.size();
        int ans = 0;
        vector<int> freq(26, 0);
        for (auto ch : s)
            freq[ch - 'a']++;

        for (int i = 0; i < t; i++) {
            vector<int> formed(26, 0);
            for (int i = 0; i < 26; i++) {
                if (i == 25) {
                    formed[0] = (formed[0] + freq[i]) % mod;
                    formed[1] = (formed[1] + freq[i]) % mod;
                } else {
                    formed[i + 1] = (formed[i + 1] + freq[i]) % mod;
                }
            }
            freq = formed;
        }
        for (auto it : freq)
            ans = (ans + it) % mod;
        return ans;
    }
};
```
['C++']