how u know that for reaching n you need n steps and for reaching n-1 you need n-1 and for going k steps it’s n-k ?
Dynamic programming
Hi,
you need to add the total number of ways to reach n. You can go to n from n-1 or n-2 … n-k. If x are the number of ways from n-1 y are the number of ways from n-2 and so on, then you need to add x+y+…
why the number of ways to reach upto k is deducted i mean why it is not consider why its taken upto n-k why add upto n-k
Because from n-k to n-1 we can go to n directly.