562. Backpack IV (和coin 2一模一样) 元素重复使用 不同order是一种情况

int backPackIV(vector<int> &nums, int target) { // write your code here const int size = nums.size(); if(size == 0){ return 0; } vector<int> dp(target + 1, 0); dp[0] = 1; for(auto a : nums){ for(int i = a; i <= target; i++){ dp[i] += dp[i - a]; } } return dp[target]; }

Comments

Popular posts from this blog

Amazon OA 763. Partition Labels

1427. Split Array into Fibonacci Sequence

05/25 周一