Memoization c++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\nconst int mod = 1e9+7;\n    //Function to calculate power of (2,x) and return an integer value\n    int power(int x){\n        int ans = 1;\n        while(x--){\n            ans = (ans*2)%mod;\n        }\n\n        return ans;\n    }\n    long long solve2(vector<int> &nums, int target, int i,vector<vector<vector<long long>>> &memo, int len){\n        if (i==nums.size()){\n            if (target==0){\n                return (power(nums.size()-len));\n            }\n            return 0;\n        }\n        if (target<0){\n            return 0;\n        }\n        if (memo[i][target][len]!=-1){\n            return memo[i][target][len];\n        }\n        \n        long long take = solve2(nums,target-nums[i],i+1,memo,len+1);\n        long long notTake = solve2(nums,target,i+1,memo,len);\n        \n        return memo[i][target][len] = (take+notTake)%mod;\n    }\n    int solve(vector<int> &nums,int k){\n        int n = nums.size();\n        vector<vector<vector<long long>>> memo(n+1,vector<vector<long long>> (k+1,vector<long long>(n+1,-1)));\n        int len = 0;\n        return solve2(nums,k,0,memo,len);\n    }\n    \n    int sumOfPower(vector<int>& nums, int k) {\n        int n = nums.size();\n        \n        return solve(nums,k);\n    }\n};\n```
['C++']