564. Combination Sum IV (backpack VI) 元素重复使用 并且 不同order也作为一种情况

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

元素重复使用多次

Comments

Popular posts from this blog

Amazon OA 763. Partition Labels

1427. Split Array into Fibonacci Sequence

05/25 周一