Approach hintTry it first, then revealHide
Split the array into maximal blocks of equal sign; a longest alternating subsequence takes exactly one element from each block, so take each block's maximum for the best sum.
Split the array into maximal blocks of equal sign; a longest alternating subsequence takes exactly one element from each block, so take each block's maximum for the best sum.