Last updated 4 years ago
Was this helpful?
Given a target find a number of distinct ways to reach the target. We do this by summing all possible ways to reach the current state.
An example is:
d = [float("inf") for i in range(n)] d[0] = 1 d[1] = 2 for i in range(2, n): d[i] = d[i - 1] + d[i - 2] return d[-1]