Light's Solution : Vanilla Recursion with DP
Complexity\n- Time complexity:\nO(NNK)\n\n- Space complexity:\nO(NNK)\n\n# Code\n\n/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n *
# Complexity\n- Time complexity:\nO(N*N*K)\n\n- Space complexity:\nO(N*N*K)\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar sumOfPower = function(nums, k) {\n\n    let dp = new Array(nums.length+1)\n    for(let i=0;i<dp.length;i++){\n        dp[i] = new Array(nums.length+1)\n        for(let j=0;j<dp[i].length;j++){\n            dp[i][j] = new Array(k+1).fill(-1)\n        }\n    }\n\n    return recur(0,k,0,nums, dp)\n};\n\nconst recur = (index, k, size, arr, dp) => {\n    if(k < 0){\n        return 0\n    }\n\n    if(k == 0){\n        let res = 1\n        for(let i=0;i<(arr.length - size);i++){\n            res = ((res*2)%1000000007)\n        }\n        return res\n    }\n\n    if(index >= arr.length){\n        return 0\n    }\n\n    if(dp[index][size][k] != -1){\n        return dp[index][size][k]\n    }\n\n    let take = 0\n    let skip = 0\n\n    take = recur(index+1, k-arr[index], size+1, arr, dp)\n    skip = recur(index+1, k, size, arr, dp)\n\n    return dp[index][size][k] = (take+skip)%1000000007\n}\n```
['JavaScript']