Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

Click here to see the full article post

In approach 4 the second equation dp[i]=(n−1)∗(dp[i−1]+dp[i−2]) need to revised to dp[i]=({\color{red} i}−1)∗(dp[i−1]+dp[i−2]) ?

@txingml Thanks for pointing it out. I have corrected the equation.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.