Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function that finds the minimum number of coins needed to make a given amount with an array of available denominations.

Hard

Problem Statement

Write a function that finds the minimum number of coins needed to make a given amount with an array of available denominations.

Sample Input

amount = 11, coins = [ 1, 5, 6 ]

Sample Output

2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Find the minimum number of coins needed for a given amount function minCoins(amount, coins) { // Initialize an array to store the minimum coins for each amount up to the given amount // Update the array using dynamic programming approach } console.log(minCoins(11, [ 1, 5, 6 ]));
Log in or sign up to run or submit your code.Log inSign up
Input
amount = 11, coins = [ 1, 5, 6 ]
Expected Output
2