Editorial for Dynamic Programming Practice 1
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
State:
dp[\(i\)] represents the max value of the set of items up to index \(i\).
Transition:
Use dp[\(i-2\)] and dp[\(i-3\)] to update dp[\(i\)]
Base Cases:
dp[0] = 0
dp[1] = a[1]
dp[2] = a[2]
Comments