3335. Total Characters in String After Transformations I
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:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int lengthAfterTransformations(string s, int t) {\n        const int MOD = 1e9 + 7;\n        int mp[26] = {0}; // Array to store frequency of each character from \'a\' to \'z\'\n\n        // Count frequency of each character in the string\n        for (char i : s) {\n            mp[i - \'a\']++;\n        }\n\n        // Apply transformations\n        for (int step = 0; step < t; ++step) {\n            int temp[26] = {0}; // Temporary array to store new character frequencies after transformation\n\n            for (int i = 0; i < 26; ++i) {\n                int cnt = mp[i];\n                cnt %= MOD; // Ensure cnt stays within the MOD range\n\n                if (i == 25) { // \'z\' case\n                    temp[0] = (temp[0] + cnt) % MOD; // Corresponds to \'a\'\n                    temp[1] = (temp[1] + cnt) % MOD; // Corresponds to \'b\'\n                } else { \n                    temp[i + 1] = (temp[i + 1] + cnt) % MOD; // Move to the next character\n                }\n            }\n            // Copy transformed counts back to mp\n            for (int i = 0; i < 26; ++i) {\n                mp[i] = temp[i];\n            }\n        }\n\n        // Calculate the total length after transformations\n        int cnt = 0;\n        for (int i = 0; i < 26; ++i) {\n            cnt = (cnt + mp[i]) % MOD;\n        }\n\n        return cnt;\n    }\n};\n\n```
['C++']