Simple and Easy JAVA Solution using Memoization
Intuition\n\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- Tim
# Intuition\n![Screenshot 2024-11-09 at 2.22.59\u202FPM.png](https://assets.leetcode.com/users/images/f85bb1a0-5883-4eaa-9b09-f154ad3f0c4a_1731142391.0736222.png)\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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    int MOD = (int)(Math.pow(10,9) + 7);\n    Integer dp[][];\n    public int lengthAfterTransformations(String s, int t) {\n        dp = new Integer[26][t+1];\n        int ans = 0;\n\n        for(char ch : s.toCharArray()){\n            ans = (ans + helper(ch-\'a\',t)) % MOD;\n        }\n\n        return ans;\n    }\n\n    private int helper(int ch,int t){\n        if(ch + t <= 25)\n            return 1;\n        \n        if(dp[ch][t] != null)\n            return dp[ch][t];\n        \n        return dp[ch][t] = (helper(0,t - (25 - ch + 1)) + helper(1,t - (25 - ch + 1)))%MOD;\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']