Meta Interview Question

Max sum of non-adjacent value combination in an array.

Interview Answers

Anonymous

Feb 21, 2013

dp[i] = max(dp[i-1],a[i]+dp[i-2])

Anonymous

Oct 14, 2012

That is a standard DP. The sample problem of the online interviewstreet site (if you mean that with the pegs) is a simple backtracking problem doable in about 15-20 LOC. No mind-breaking stuff needed.