Vaults stand in a circle; vault i holds gold[i] bars and the last vault is next to the first. Opening a vault triggers the alarms of both neighbours, so no two adjacent vaults may be opened. Return the maximum number of bars you can take.
Examples
Input: gold = [2, 7, 9, 3, 1]
Output: 11
Explanation: open vaults 0 and 2 (2 + 9); vault 4 is adjacent to vault 0, so it stays shut.
Input: gold = [3, 8]
Output: 8
Constraints
1 <= len(gold) <= 10**50 <= gold[i] <= 10**4- Target complexity: O(n) time.
Goals
- Reduce a circular constraint to two runs of a linear recurrence
- Reuse a helper for the linear take-or-skip problem