mirror of
https://github.com/CyC2018/CS-Notes.git
synced 2025-07-05 16:17:45 +08:00
auto commit
This commit is contained in:
@ -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++) { //将逆序遍历改为正序遍历
|
||||||
|
Reference in New Issue
Block a user