Click here to see the full article post
my AC solution with DFS,similar to arppoach 1:
Maybe a missing test case mentioned in this post : https://leetcode.com/discuss/110931/a-missing-test-case
It seems that in ruby the DP approaches hit the time limit. Is it possible that it's incorrectly set for this problem?
also hit the time limit using bottom-up DP approach in Python 3 :( ~20ms for the failing test case on my local machine
Can anybody explain to me why we need
count[rem - 1] = (min == Integer.MAX_VALUE) ? -1 : min;? Thanks
@bluezebra min is initialized as Integer.MAX_VALUE if that is never replaced, means there's no way to make the change. E.g. amount = 1, no coins are available, then min = Integer.MAX_VALUE, so return -1 signaling that no solution is found. Else, just return the min, because min has been updated throughout to reflect the smallest number of ways to make change.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.