Simple C++ Solution Using DP
\nclass Solution {\npublic:\n    \n    long long power(long long a, long long n)\n    {\n        long long res = 1;\n        while(n > 0)\n        {\n          
```\nclass Solution {\npublic:\n    \n    long long power(long long a, long long n)\n    {\n        long long res = 1;\n        while(n > 0)\n        {\n            if(n % 2)\n            {\n                res = (res * a) % mod;\n                n--;\n            }\n            else\n            {\n                a = (a * a) % mod;\n                n = n / 2;\n            }\n        }\n        \n        return res % mod;\n    }\n    \n    int mod = 1e9 + 7;\n    int f(long long ind, long long sum, vector<int> &nums, int k, vector<vector<long long>> &dp)\n    {\n        int n = nums.size();\n        \n        if(sum == k)\n            return power(2ll, (long long)n - ind);\n        else if(sum > k)\n            return 0;\n        if(ind >= n)\n            return 0;\n        \n        if(dp[ind][sum] != -1)\n            return dp[ind][sum];\n        \n        long long take = f(ind + 1, sum + nums[ind], nums, k, dp);\n        long long notTake = 2 * f(ind + 1, sum, nums, k, dp);\n        \n        return dp[ind][sum] = (take + notTake) % mod;\n    }\n    \n    int sumOfPower(vector<int>& nums, int k) {\n        \n        int n = nums.size();\n        vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, -1));\n        \n        return f(0, 0, nums, k, dp);\n    }\n};\n\n\n\n// USING 3D DP\n// -----------\n\n// class Solution {\n// public:\n    \n//     long long power(long long a, long long n)\n//     {\n//         long long res = 1;\n//         while(n > 0)\n//         {\n//             if(n % 2)\n//             {\n//                 res = (res * a) % mod;\n//                 n--;\n//             }\n//             else\n//             {\n//                 a = (a * a) % mod;\n//                 n = n / 2;\n//             }\n//         }\n        \n//         return res % mod;\n//     }\n    \n//     int mod = 1e9 + 7;\n//     int f(long long ind, long long cnt, long long sum, vector<int> &nums, int k, vector<vector<vector<long long>>> &dp)\n//     {\n//         int n = nums.size();\n        \n//         if(sum == k)\n//             return power(2ll, (long long)n - cnt);\n//         else if(sum > k)\n//             return 0;\n//         if(ind >= n)\n//             return 0;\n        \n//         if(dp[ind][cnt][sum] != -1)\n//             return dp[ind][cnt][sum];\n        \n//         long long take = f(ind + 1, cnt + 1, sum + nums[ind], nums, k, dp);\n//         long long notTake = f(ind + 1, cnt, sum, nums, k, dp);\n        \n//         return dp[ind][cnt][sum] = (take + notTake) % mod;\n//     }\n    \n//     int sumOfPower(vector<int>& nums, int k) {\n        \n//         int n = nums.size();\n//         vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(k + 1, vector<long long>(k + 1, -1)));\n        \n//         return f(0, 0, 0, nums, k, dp);\n//     }\n// };\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']