We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- The Coin Change Problem
- Discussions
The Coin Change Problem
The Coin Change Problem
Sort by
recency
|
25 Discussions
|
Please Login in order to post a comment
Python, top down
I wonder if the official answers are correct. For the run case getWays(4, [1,2,3]), my answer is 2 ({2, 2} and {1, 3}), but the official answer is 4. For the run case getWays(10, [2,5,3,6]), my answer is 12 but the official answer is 5.
include
include
using namespace std;
vector coinChangeGreedy(const vector& coins, int amount) { vector result(coins.size(),0); for(int i=coins.size()-1;i>=0;i--) { result[i] = amount/coins[i]; amount %= coins[i]; } return result; }
int main() { vector coins = {1,5,10,25}; int amount =47;
}
Java O(n*m)