You are given a circular integer array code and an integer k. Return a new array computed from the original values: if k is positive, replace each element with the sum of the next k elements; if k is negative, use the previous -k elements; if k is zero, use zero. Indices wrap around either end of the array. Every replacement uses the original array, so no replacement affects another.
Example 1:
Input: code = [1,2,3]
k = 1
Output: [2,3,1]Explanation: Use the next original element at every position. After 3, the circular array wraps back to 1, giving [2,3,1].
Example 2:
Input: code = [1,2,3]
k = -1
Output: [3,1,2]Explanation: Use the previous original element at every position. Before 1, the circular array wraps back to 3, giving [3,1,2].
Example 3:
Input: code = [7]
k = 0
Output: [0]Explanation: With k = 0, every entry becomes zero. This array has one entry, so the result is [0].
Constraints:
1 <= code.length <= 1001 <= code[i] <= 100-(code.length - 1) <= k <= code.length - 1