functionminNumberOfCoinsForChange(n, denoms) {denoms.sort((a, b) => a - b);constcoins=newArray(n +1).fill(Infinity); coins[0]=0;for (constdenomof denoms) {for (let i =1; i < n +1; i++) {if (denom > i) continue; coins[i] =Math.min(coins[i], coins[i - denom] +1); } }return coins[n] ===Infinity?-1: coins[n];}// Do not edit the line below.exports.minNumberOfCoinsForChange = minNumberOfCoinsForChange;