Algorithm to find the maximum subsequence of an array of positive numbers . Catch : No adjacent elements allowed

前端 未结 13 1124
甜味超标
甜味超标 2020-12-24 04:42

For example, given

A = [1,51,3,1,100,199,3], maxSum = 51 + 1 + 199 = 251.

clearly max(oddIndexSum,evenIndexSum) does not

13条回答
  •  时光取名叫无心
    2020-12-24 05:07

    MarkusQ's code appears to completely skip over a[2]. I'm not smart enough to figure out where it should figure into the reckoning.

提交回复
热议问题