Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1.     int combinationSum4(vector<int>& nums, int target) {
  2.         vector<int> memo(target + 1);
  3.         memo[0] = 1;
  4.        
  5.         for (int s = 1; s < memo.size(); ++s) {
  6.             for (auto x : nums) {
  7.                 if (s - x >= 0) memo[s] += memo[s - x];
  8.             }
  9.         }
  10.        
  11.         return memo.back();
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement