Easy C++ Solution || (Using 2D DP) ✅✅
Code\n\nclass Solution {\npublic:\n    int mod=pow(10,9)+7;\n    int power(int x){\n        int ans = 1;\n        while(x--)\n            ans = (ans * 2) % mod;
# Code\n```\nclass Solution {\npublic:\n    int mod=pow(10,9)+7;\n    int power(int x){\n        int ans = 1;\n        while(x--)\n            ans = (ans * 2) % mod;\n        return ans;\n    }\n    int helper(vector<int>& nums,int i,long long sum,int k,vector<vector<int>> &dp){\n        if(sum>k){\n            return 0;\n        }\n        if(sum==k){\n            return power(nums.size()-i);\n        }\n        if(i>=nums.size()){\n            return 0;\n        }\n        if(dp[i][sum]!=-1){\n            return dp[i][sum];\n        }\n        int take=helper(nums,i+1,sum+nums[i],k,dp)%mod;\n        int ntake=2*helper(nums,i+1,sum,k,dp)%mod;\n        return dp[i][sum]=(take+ntake)%mod;\n\n    }\n    int sumOfPower(vector<int>& nums, int k) {\n        int n=nums.size();\n        vector<vector<int>> dp(n,vector<int>(k+1,-1));\n        return helper(nums,0,0,k,dp);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C++']