Advertisement
nikunjsoni

377

Jun 12th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int combinationSum4(vector<int>& nums, int target) {
  4.         vector<unsigned int> result(target + 1);
  5.         result[0] = 1;
  6.         for (int i = 1; i <= target; ++i) {
  7.             for (int x : nums) {
  8.                 if (i >= x) result[i] += result[i - x];
  9.             }
  10.         }
  11.         return result[target];
  12.     }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement