...

/

MaxSum Subsequence - Nonadjacent Elements

MaxSum Subsequence - Nonadjacent Elements

Find the maximum sum of a subsequence made up of nonadjacent elements in an array.

Statement

Find the maximum sum of a subsequence in a given array such that no consecutive elements are part of this subsequence.

Examples

Consider the following examples:

  • In the example below, the maximum sum of a subsequence with no consecutive elements is 2525:
g d2 1 6 10 14 -5 -1 2 -1 3 d max sum = 25

Note: We did not pick 1010 and ...