Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc79618

Browse files
committed
dd
1 parent 6a91cf8 commit fc79618

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

6/CombinationCoins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ private void helper(int target, int[] coins, int index, List<Integer> cur, List<
5858
// 中止: index == coins.length
5959
// 更好的方法是在前面的层里面减少冇必要的DFS分支数
6060
// coins.length - 1 是最后一个我地使用的银币,并且我所做是为了得到target/coins[coins.length - 1]
61-
if (index == coins.length - 1) {
61+
if (index == coins.length - 1) { // length - 1
6262
if (target % coins[coins.length - 1] == 0) { // 能不能整除?
6363
cur.add(target / coins[coins.length - 1]); // 可以整除,就除吧
64-
result.add(new ArrayList<Integer>(cur));
65-
cur.remove(cur.size() - 1);
64+
result.add(new ArrayList<Integer>(cur)); // 注意result添加一个List<Integer>的方式
65+
cur.remove(cur.size() - 1); // List的大小用size()
6666
}
6767
return;
6868
}

0 commit comments

Comments
 (0)