Sunday, August 26, 2012

Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.

Example 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7).

2 comments :

Swagat said...

http://swagatech.blogspot.com/2012/08/max-sum-of-non-adjacent-numbers-in-array.html

Swagat said...
This comment has been removed by the author.