A common greedy approach: sum values at odd positions, sum values at even positions, take the max. This fails. Example: . Odd-position sum = . Even-position sum = .
But picking houses and gives , which is better than both. The greedy approach fails because sometimes skipping an odd-positioned house for a larger even-positioned one (or vice versa) gives a better total. You can't decide locally. You need the global picture. This is why DP is required. The next unit shows how to set up the state.