C++ || DP Memoization || Easy to Understand
ApproachHere our goal is to calculate the length of the resulting String. So I just calculated the increment for each character in the string after t transforma
# Approach\n<!-- Describe your approach to solving the problem. -->\nHere our goal is to calculate the length of the resulting String. So I just calculated the increment for each character in the string after t transformations and added them to get the result.\n\n# Complexity\n- Time complexity: O(N + 26 * T)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(26 * T)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int mod = 1e9 + 7;\n    \n    int f(char a, int t, vector<vector<int>> &dp) {\n        if (t <= 0) return 1; \n        if (dp[a - \'a\'][t] != -1) return dp[a - \'a\'][t]; \n\n        if (a == \'z\') return dp[a - \'a\'][t] = (f(\'a\', t - 1, dp) + f(\'b\', t - 1, dp)) % mod;\n        else return dp[a - \'a\'][t] = f(a + 1, t - 1, dp) % mod;\n    }\n\n    int lengthAfterTransformations(string s, int t) {\n        int sum = 0;\n        vector<vector<int>> dp(26, vector<int>(t + 1, -1)); \n\n        for (int i = 0; i < s.size(); i++) {\n            sum = (sum + f(s[i], t, dp)) % mod; \n        }\n        return sum;\n    }\n};\n\n```
['C++']