title: Why my code can't pass the test case from LeetCode 322 Coin Change?
body: <p>Link to the problem: <a href="https://leetcode.com/problems/coin-change/" rel="nofollow noreferrer">https://leetcode.com/problems/coin-change/</a><br>
  My code can't pass some test cases from LeetCode:</p>
  
  <pre><code>def coinChange(coins, amount):
      """
      :type coins: List[int]
      :type amount: int
      :rtype: int
      """
      coins.sort()
      #init the dp list
      dp = [0]+[float('inf')]*amount
      for i in coins:
          for j in range(i,amount+1):
              dp[j] = min(dp[j],int(j/i)+dp[j%i])
  
      if dp[-1]==float('inf'):
          return -1
      else:
          return dp[-1]
  
  
  #test cases1,the result should be 3    
  coins = [1, 2, 5]
  amount = 11
  print(coinChange(coins,amount))
  #test cases2,the result should be 20  
  coins = [186,419,83,408]
  amount = 6249
  print(coinChange(coins,amount))
  </code></pre>
  
  <p>it should return 20 for the second test case but now it's -1.
  I don't know why my code works on the first test case but not the second one.<br>
  Thanks</p>