We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I got your entire DP code. Only one doubt I have and it is related to ways to calculate 3 steped staircase.
Code says it is w[3] = w[0]+w[1]+2[2]=0+1+2=3 where as one can climb it with four different combinations.. Here it is 1 (1+1+1), 2 as (1+2), 3 as (2+1) and fourth as (3) all 3 steps in a go.
Am i missing something?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Davis' Staircase
You are viewing a single comment's thread. Return to all comments →
Thank you for your detailed explanation.
I got your entire DP code. Only one doubt I have and it is related to ways to calculate 3 steped staircase.
Code says it is w[3] = w[0]+w[1]+2[2]=0+1+2=3 where as one can climb it with four different combinations.. Here it is 1 (1+1+1), 2 as (1+2), 3 as (2+1) and fourth as (3) all 3 steps in a go.
Am i missing something?