You are viewing a single comment's thread. Return to all comments →
Java Solution
int[] dp=new int[n+1]; dp[0]=1; dp[1]=1; for(int i=2;i<=n;i++) { if(i==2) { dp[i]=dp[i-1]+dp[i-2]; } else { dp[i]=dp[i-1]+dp[i-2]+dp[i-3]; } } return dp[n]; }
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 →
Java Solution