Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array.
The first one in the array is considered next to the last one in the array. Use Dynamic Programming to solve it.