Recursion+Dynamic Programming type approach
Intuition\nIf character+t>=26, means it will cross z and double itself while converting to a and b.\n\n# Approach\nSo lets convert every number to a and b if it
# Intuition\nIf character+t>=26, means it will cross z and double itself while converting to a and b.\n\n# Approach\nSo lets convert every number to a and b if it is converting according to above criteria, and then a will require t>=26 to double again to a and b, whereas b will require t>=25 to double again. So use recursion, for a, t-26 each time a doubles into a and b. For b,t-25 each time b doubles into and b. Now, since every letter will be converted to a and b, there will be repetitions, and so use dynamic programming approach, so for a particular value of t what is the answer a gives. Similarly for b. \n\n# Complexity\n- Time complexity:\n26* 1e5 *2\n\n- Space complexity:\nvectors used= 1e5*2\nrecursion stack space=(t/26) *2\n\n# Code\n```cpp []\nclass Solution {\nconst int MOD=(int)(1e9+7);\ntypedef long long ll;\nprivate:\n\n    int solveB(int t,vector<int>&a,vector<int>&b){\n        if(t<=24){\n            // if(t<0){\n            //     return 0;\n            // }\n            return 1;\n        }\n        if(b[t]!=-1){\n            return b[t];\n        }\n        return b[t]=(solveA(t-25,a,b)+solveB(t-25,a,b))%MOD;\n    }\n\n    int solveA(int t,vector<int>&a,vector<int>&b){\n        if(t<=25){\n            // if(t<0){\n            //     return 0;\n            // }\n            return 1;\n        }\n        if(a[t]!=-1){\n            return a[t];\n        }\n        return a[t]=((solveA(t-26,a,b))+(solveB(t-26,a,b)))%MOD;\n    }\npublic:\n    int lengthAfterTransformations(string s, int t) {\n        int n=s.length();\n        ll ans=0;\n        vector<int>a(1e5+1,-1);\n        vector<int>b(1e5+1,-1);\n        for(int i=0;i<n;i++){\n            int num=s[i]-\'a\';\n            if((t-(26-num))>=0){\n                ans+=(solveA(t-(26-num),a,b)+solveB(t-(26-num),a,b))%MOD;\n            }\n            else{\n                ans+=1;\n            }\n            ans=ans%MOD;\n        }\n\n        return ans%MOD;\n    }\n};\n```
['C++']