Skip to content

Commit 5808446

Browse files
edit 377
1 parent fa80573 commit 5808446

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Your ideas/fixes/algorithms are more than welcome!
208208
|385|[Mini Parser](https://leetcode.com/problems/mini-parser/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MiniParser.java)| O(n)|O(h) | Medium| Stack
209209
|382|[Linked List Random Node](https://leetcode.com/problems/linked-list-random-node/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_382.java)| O(1)|O(n) | Medium| Reservoir Sampling
210210
|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory/)|[Solution](../master/src/main/java/com/fishercoder/solutions/DesignPhoneDirectory.java)| O(1)|O(n) | Medium|
211-
|377|[Combination Sum IV](https://leetcode.com/problems/combination-sum-iv/)|[Solution](../master/src/main/java/com/fishercoder/solutions/CombinationSumIV.java)| O(?)|O(?) | Medium|
211+
|377|[Combination Sum IV](https://leetcode.com/problems/combination-sum-iv/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_377.java)| O(?)|O(?) | Medium|
212212
|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_376.java)| O(n)|O(1) | Medium| DP, Greedy
213213
|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_375.java)| O(n^2)|O(n^2) | Medium| DP
214214
|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower/)|[Solution](../master/src/main/java/com/fishercoder/solutions/GuessNumberHigherorLower.java)| O(logn)|O(1) | Easy| Binary Search

src/main/java/com/fishercoder/solutions/CombinationSumIV.java renamed to src/main/java/com/fishercoder/solutions/_377.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import java.util.ArrayList;
66
import java.util.Arrays;
77
import java.util.List;
8-
/**Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
8+
/**Given an integer array with all positive numbers and no duplicates,
9+
* find the number of possible combinations that add up to a positive integer target.
910
1011
Example:
1112
@@ -24,14 +25,15 @@
2425
Note that different sequences are counted as different combinations.
2526
2627
Therefore the output is 7.
28+
2729
Follow up:
2830
What if negative numbers are allowed in the given array?
2931
How does it change the problem?
3032
What limitation we need to add to the question to allow negative numbers?*/
31-
public class CombinationSumIV {
32-
//since this question doesn't require to return all the combination result, instead, it just wants one number, we could use DP
33-
//the idea is similar to Climbing Stairs.
34-
//adopted this solution: https://discuss.leetcode.com/topic/52186/my-3ms-java-dp-solution
33+
public class _377 {
34+
/**since this question doesn't require to return all the combination result, instead, it just wants one number, we could use DP
35+
the idea is similar to Climbing Stairs.
36+
adopted this solution: https://discuss.leetcode.com/topic/52186/my-3ms-java-dp-solution*/
3537
public int combinationSum4(int[] nums, int target){
3638
Arrays.sort(nums);
3739
int[] result = new int[target+1];
@@ -68,7 +70,7 @@ private void backtracking(int start, int[] nums, int target, ArrayList temp,
6870
}
6971

7072
public static void main(String...strings){
71-
CombinationSumIV test = new CombinationSumIV();
73+
_377 test = new _377();
7274
int[] nums = new int[]{1,2,3};
7375
int target = 4;
7476
CommonUtils.printListList(test.combinationSum4_printout(nums, target));

0 commit comments

Comments
 (0)