DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
DP

Coin Change

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Coin Change** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** BFS or bottom-up DP, init with infinity **Edge Cases to Consider:** - (1) Amount = 0 - (2) No combination sums to amount - (3) Coins larger than amount

Examples

Example 1
Input: [1,2,5], 11
Output: 3
Explanation: 5+5+1
Example 2
Input: [2], 3
Output: -1
Explanation: Impossible
Example 3
Input: [1], 0
Output: 0
Explanation: Amount 0

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Amount = 0
  • ▪No combination sums to amount
  • ▪Coins larger than amount
Frequently Asked At
AmazonGoogleMicrosoftMetaAdobeFlipkartZomato