Count Frequency - O(N)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n- update the frequency array  with corresponding next char in each transformation and
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n- update the frequency array  with corresponding next char in each transformation and increment the freq of a and b \'z\' number of times at each transformation.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. count the frequency\n2. update the frequency using new array for every char to its next char\n3. increment the the freq of a and b by \'z\' times\n4. update the original freq array to new freq array\n\n# Complexity\n- Time complexity: O(t*26*26)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(t*26)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int mod = 1e9+7;\n    int lengthAfterTransformations(string s, int t) {\n        int freq[26];\n        for(auto x: s) freq[x-\'a\']++;\n        long long count = 0;\n\n        for(int i = 0; i<t; i++) {\n            int freq2[26] = {0};\n            for(int j = 0 ; j<25; j++) {\n                freq2[j+1] = freq[j];\n                freq[j] = 0;\n            }\n            if(freq[25]  > 0) {\n                freq2[0] = (freq2[0] + (freq[25]))%mod;\n                freq2[1] = (freq2[1] + freq[25])%mod;\n                freq[25] = 0;\n            }\n            for(int itr = 0; itr<26; itr++) freq[itr] = freq2[itr];\n        }\n\n        for(int i =0; i<26; i++) {\n            count+=freq[i];\n            count = count%mod;\n        }\n\n        return count;\n    }\n};\n```
['C++']