Video Explanation (Everything explained step by step from scratch)
Explanation\n\nClick here for the video\n\n# Code\n\nconst int M = 1e9+7;\n\nint dp[101][101][101];\n\nclass Solution {\n    \n    int n;\n    vector<int> arr;\
# Explanation\n\n[Click here for the video](https://youtu.be/EW31-2eM7Ww)\n\n# Code\n```\nconst int M = 1e9+7;\n\nint dp[101][101][101];\n\nclass Solution {\n    \n    int n;\n    vector<int> arr;\n    \n    int CountSubsequences (int ind, int sum, int cnt) {\n        if (ind == n) return (sum == 0 && cnt == 0);\n        if (cnt < 0) return 0;\n        if (sum < 0) return 0;\n        \n        int& ans = dp[ind][sum][cnt];\n        if (ans != -1) return ans;\n        \n        ans = CountSubsequences (ind+1, sum, cnt);\n        ans = (ans + CountSubsequences(ind+1, sum-arr[ind], cnt-1)) % M;\n        return ans;\n    }\n    \npublic:\n    int sumOfPower(vector<int>& nums, int k) {\n        memset(dp, -1, sizeof(dp));\n        \n        n = nums.size();\n        arr = nums;\n        int ans = 0;\n        \n        vector<long long> pwr_2(n+1, 1);\n        for (int j = 1; j <= n; j ++)\n            pwr_2[j] = (pwr_2[j-1] * 2) % M;\n        \n        for (int cnt = 1; cnt <= n; cnt ++) {\n            long long total = CountSubsequences (0, k, cnt);\n            ans = (ans + (total * pwr_2[n-cnt]) % M) % M;\n        }\n        return ans;\n    }\n};\n```
['C++']