auto commit
This commit is contained in:
parent
a9d58b91de
commit
ae7fd87fc0
@ -912,6 +912,7 @@ return -1.
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
public int coinChange(int[] coins, int amount) {
|
public int coinChange(int[] coins, int amount) {
|
||||||
|
if (amount == 0 || coins == null) return 0;
|
||||||
int[] dp = new int[amount + 1];
|
int[] dp = new int[amount + 1];
|
||||||
for (int coin : coins) {
|
for (int coin : coins) {
|
||||||
for (int i = coin; i <= amount; i++) { //将逆序遍历改为正序遍历
|
for (int i = coin; i <= amount; i++) { //将逆序遍历改为正序遍历
|
||||||
|
@ -912,6 +912,7 @@ return -1.
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
public int coinChange(int[] coins, int amount) {
|
public int coinChange(int[] coins, int amount) {
|
||||||
|
if (amount == 0 || coins == null) return 0;
|
||||||
int[] dp = new int[amount + 1];
|
int[] dp = new int[amount + 1];
|
||||||
for (int coin : coins) {
|
for (int coin : coins) {
|
||||||
for (int i = coin; i <= amount; i++) { //将逆序遍历改为正序遍历
|
for (int i = coin; i <= amount; i++) { //将逆序遍历改为正序遍历
|
||||||
|
Loading…
x
Reference in New Issue
Block a user