How to select a subset from an array so that the sum of the elements of the subset is maximum ?
But there is one interesting condition : -
1)When I select any particular element, I am forced to select the next and previous element as well.
What will be the recurrence-relation/dynamic-programming approach to solve this problem?
We select ‘2’ and ‘8’ and our final answer is, hence :- [1+2+3] + [7+8+9] = 30
If you select ‘2’ and ‘4’, answer will be= 1+2+3+4+5
I have formed a recurrence relation but not very sure about it…
This problem has been created by me , btw…
Update :- I finally discovered a solution on my own .