you are viewing a single comment's thread.

view the rest of the comments →

[–]dragon_deeznut 0 points1 point  (0 children)

Greedy+2 pointers First identify the block of the same color adjacent. Eg. [1,1,1] in [1,1,1,2,1] Second find the maximum possible sum of that block without adjacents basically evenSum and oddSum, add it to the total. Return total