Posted by mpweiher 9/12/2025
Second, it's a covert test for culture fit. Are you young (and thus still OK with grinding for tests)? Are you following industry trends? Are you in tune with the Silicon Valley culture? For the most part, a terrible thing to test, but also something that a lot of "young and dynamic" companies want to select for without saying so publicly. An AI startup doesn't want people who have family life and want to take 6 weeks off in the summer. You can't put that in a job req, but you can come up with a test regime that drives such people away.
It has very little to do with testing the skills you need for the job, because quite frankly, probably fewer than 1% of the SWE workforce is solving theoretical CS problems for a living. Even if that's you, that task is more about knowing where to look for answers or what experiments to try, rather than being able to rattle off some obscure algorithm.
(if you have enough time)
Populate a 2d lookup array. $7,50 becomes arr[750] = [7,1,0,0,0,0] which represents [7x100,1x50,0x25,0x10,0x5,0x1]
With each loop check if the array entry exists, if so check if that number of coins is larger. [7,1,0... is better than [7,0,2...] because 8 is a better solution than 9!
coins = [100,50,25,10,5,1]
change = 1234;
result = [0,0,0,0,0,0];
for(i=0:i<coins.length;i++){
while(change>coins[i]){
result[i]++;
change-=coins[i];
}
}
//[12,0,1,1,4]
Coudnt help myself sorry function coin_change(change) {
const coins = [25, 10, 5, 1]
for (const coin of coins) {
const n = change / coin | 0
change -= n * coin
console.log(coin, n)
}
}
coin_change(25+10+5+1) [100,500,25,10,5,1].map(coin=>{
n = change / coin | 0
change %= coin;
return n
})
Coding on a Phone is hell change = 12345;
console.log(
[100,500,25,10,5,1].map(
coin=>[change/coin|0,change%=coin][0]
)
)