Grokking Dynamic Programming Patterns for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Why is this check done in the recursive helper function instead of in the count_...

Gary

May 10, 2022

Why is this check done in the recursive helper function instead of in the count_change function? denominations list never changes, right?

n = len(denominations) if n == 0

1

0

Comments
Comments
S
Shan 3 years ago

agreed this is also the case in the cutting rods problem i believe

K
kirti verma3 years ago

yeah you can check it before calling the recursive function and return as well. I guess this is only to handle the edge case of an empty list

On this page