Class Solution
java.lang.Object
g0301_0400.s0377_combination_sum_iv.Solution
377 - Combination Sum IV.<p>Medium</p>
<p>Given an array of <strong>distinct</strong> integers <code>nums</code> and a target integer <code>target</code>, return <em>the number of possible combinations that add up to</em> <code>target</code>.</p>
<p>The test cases are generated so that the answer can fit in a <strong>32-bit</strong> integer.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3], target = 4</p>
<p><strong>Output:</strong> 7</p>
<p><strong>Explanation:</strong></p>
<pre><code> The possible combination ways are:
(1, 1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 3)
(2, 1, 1)
(2, 2)
(3, 1)
Note that different sequences are counted as different combinations.
</code></pre>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [9], target = 3</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 200</code></li>
<li><code>1 <= nums[i] <= 1000</code></li>
<li>All the elements of <code>nums</code> are <strong>unique</strong>.</li>
<li><code>1 <= target <= 1000</code></li>
</ul>
<p><strong>Follow up:</strong> What if negative numbers are allowed in the given array? How does it change the problem? What limitation we need to add to the question to allow negative numbers?</p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
combinationSum4
public int combinationSum4(int[] nums, int target)
-