प्रश्न
00:00

23. Coin Change

मध्यमडायनेमिक प्रोग्रामिंगAmazonMicrosoft

Given coin denominations and an amount, return the minimum number of coins needed, or -1 if the amount cannot be formed.

उदाहरण 1:

इनपुट: coins = [1,2,5], amount = 11
आउटपुट: 3

उदाहरण 2:

इनपुट: coins = [2], amount = 3
आउटपुट: -1

सीमाएँ:

  • 1 <= coins.length <= 12
  • 0 <= amount <= 10^4
मुख्य कोड मोड
● अपने आप सहेजा गयापंक्ति 1, कॉलम 1