Skip to content

Instantly share code, notes, and snippets.

@christopherwxyz
Created August 24, 2022 19:45
Show Gist options
  • Save christopherwxyz/72dcae7dde20a620c20b3547b9f747dd to your computer and use it in GitHub Desktop.
Save christopherwxyz/72dcae7dde20a620c20b3547b9f747dd to your computer and use it in GitHub Desktop.
possibleSums
function solution(coins, quantity) {
let s = new Set([0]);
for (let i in coins) {
for (let entry of [...s]) {
for (let j = quantity[i]; j; ) {
s.add(coins[i] * j-- + entry);
}
}
}
return s.size - 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment