So
dpf[] = dpf[j] + max[dpf[i-1], dpf[i-2]]
and
dpb[i] = … is the bottoms up approach right .
But I don’t understand the last relation
ans = max (ans , dpf[i] +dpb[i] - a[i] ) , what will be ans here ? please do mark any reference links if possible.