Just transform on frequency one by one
Intuition\n- t is 1e5, so if we do transfrorm one by one on char frequency, instead of on string s, it will be linear on t and pass all tests for sure.\n \n# Co
# Intuition\n- `t` is `1e5`, so if we do transfrorm one by one on char frequency, instead of on string `s`, it will be linear on `t` and pass all tests for sure.\n \n# Code\n```cpp []\nclass Solution {\npublic:\n    int lengthAfterTransformations(string s, int t) {\n        array<int,26> freq;\n        for(auto c : s) freq[c-\'a\']++;\n        for(int i = 0; i < t; ++i) {\n            array<int,26> freq2;\n            copy(freq.begin(), freq.begin() + 25, freq2.begin()+1);\n            freq2[0] = freq[25];\n            freq2[1] = (freq2[1] +freq[25]) % 1\'000\'000\'007;\n            freq = std::move(freq2);\n        }\n        return accumulate(freq.begin(), freq.end(), 0, [](auto sum, auto a) { return (sum + a) % 1\'000\'000\'007; });\n    }\n};\n```
['C++']