🔥Java Solution || Dp (Memoization)
\nclass Solution {\n    private int mod = 1000000007;\n\n    public int sumOfPower(int[] nums, int k) {\n        int[][][] dp = new int[nums.length][k+1][nums.l
```\nclass Solution {\n    private int mod = 1000000007;\n\n    public int sumOfPower(int[] nums, int k) {\n        int[][][] dp = new int[nums.length][k+1][nums.length+1];\n        for(int[][] arr : dp) {\n            for(int[] ar : arr) Arrays.fill(ar, -1);\n        }\n        return helper(nums, 0, k, 0, k, dp);\n    }\n\n    private int helper(int[] nums, int index, int sum, int len, int k, int[][][] dp) {\n        if(sum == 0) return (int)(Math.pow(2, nums.length-len) % mod);\n        if(index == nums.length) return 0;\n        if(dp[index][sum][len] != -1) return dp[index][sum][len];\n\n        int count = 0;\n        if(sum - nums[index] >= 0) count += (helper(nums, index+1, sum-nums[index], len+1, k, dp)) % mod;\n        count += (helper(nums, index+1, sum, len, k, dp)) % mod;\n        \n        return dp[index][sum][len] = count % mod;\n    }\n}\n```
['Java']