Easiest Solution 💡
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    int mod = 1000000007;\n\n    public int lengthAfterTransformations(String s, int t) {\n        int[] cnt = new int[26];\n        for (int i = 0; i < s.length(); i++) {\n            cnt[s.charAt(i) - \'a\']++;\n        }\n        int ans = s.length();\n\n        while (t > 0) {\n            ans = ((ans%mod) + cnt[25])%mod;\n\n            int pre = cnt[25];\n            for (int i = 0; i < 26; i++) {\n                int te = cnt[i];\n                cnt[i] = 0;\n                cnt[i] =(cnt[i]+ pre)%mod;\n                if (i == 1) {\n                    cnt[i] = (cnt[i]+cnt[25])%mod;\n                }\n              \n                pre = te;\n            }\n\n            t--;\n        }\n        return ans;\n    }\n}\n```
['Array', 'Java']