Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int combinationSum4(vector<int>& nums, int n) {
- int i,j;
- vector<unsigned long long int>a(n+1);
- //memset(a,0,sizeof(a));
- a[0]=1;
- for(i=1;i<=n;i++)
- {
- for(j=0;j<nums.size();j++)
- {
- if(nums[j]<=i)
- {
- a[i]+=a[i-nums[j]];
- }
- }
- }
- return a[n];
- }
- };
Add Comment
Please, Sign In to add comment