Max sum of non-adjacent values in a circular array
A park has sprinklers arranged in a closed ring around a lawn. Each sprinkler waters a known area, but two neighbouring sprinklers share a pipe, and turning both on drops the pressure too far. Because the ring is closed, the last sprinkler is also a neighbour of the first.
Implement maxRingSum(values). It returns the largest total you can get by choosing positions of values such that no two chosen positions are neighbours on the ring.
maxRingSum(values) // => number
values holds non-negative integers. Position i is a neighbour of i - 1 and i + 1, and position 0 is a neighbour of the last position.0.0. With one value, that value can be chosen (it is not its own neighbour). With two values, they are neighbours, so only one can be chosen.maxRingSum([2, 3, 2]); // => 3 (positions 0 and 2 are neighbours on the ring)
maxRingSum([4, 1, 2, 7]); // => 8 (1 + 7; 4 and 7 are neighbours on the ring)
maxRingSum([6, 2, 3, 9, 1]); // => 15 (6 + 9; positions 0 and 3 are not neighbours)
maxRingSum([5]); // => 5
maxRingSum([5, 8]); // => 8
maxRingSum([]); // => 0