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 = [6, 3, 8, 4, 9]
Output: 17
Explanation: open vaults 2 and 4 (8 + 9). Vaults 0, 2 and 4 would give 23, but vault 4 is next to vault 0.
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