▲ | meindnoch 5 days ago | |
Any problem can be solved by a sufficient number of nested for loops. (if you have enough time) | ||
▲ | 6510 4 days ago | parent | next [-] | |
One level of nested for loop for each type of coin. (Run them until i*coin is larger than the input) 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! | ||
▲ | scotty79 4 days ago | parent | prev [-] | |
And a stack. |