recursion + memorization DP
IntuitionApproachComplexity
Time complexity:

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

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

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int lengthAfterTransformations(String s, int t) {
        long [] dict = new long[26];
        long[][] dp = new long[26][t + 1];
                int mod = (int)(1e9 + 7);
        for (int i = 0; i < 26; ++i) {
            dict[i] = lengthAfterT(i, t, dp) % mod;
        }

        int res = 0;


        for (int i = 0; i < s.length(); ++ i) {
            char c = s.charAt(i);
            res = (int)(res + dict[c -'a']) % mod;
        }

        return res;
        
    }

    public long lengthAfterT(int index, int t, long[][] dp) {
        if (t == 0) {
            return 1L;
        } 

        if (dp[index][t] != 0) {
            return dp[index][t];
        }
        
        long res = 0;
        int mod = (int)(1e9 + 7);
        if (index == 25) {
            res = (lengthAfterT(0, t - 1, dp) + lengthAfterT(1, t - 1, dp)) % mod;
        } else {
            res = lengthAfterT(index + 1, t - 1, dp) % mod;
        }

        dp[index][t] = res;
        return res;
    }
}
```
['Java']