Dynamic Programming (DP) in python
@cache
def call(ind):
if ind == 0 or ind == 1:
return 1
return call(ind-1) + call(ind-2)
By just writing, cache
before a function, it is cached based on the parameters.
@cache
def call(ind):
if ind == 0 or ind == 1:
return 1
return call(ind-1) + call(ind-2)
By just writing, cache
before a function, it is cached based on the parameters.