You have a bomb to defuse, and your time is running out! Your informer gives you a circular array code of length n and a key k.
To decrypt the code, replace every number at the same time:
- If
k > 0, replace the ith number with the sum of the next k numbers.
- If
k < 0, replace the ith number with the sum of the previous k numbers.
- If
k == 0, replace the ith number with 0.
Because code is circular, the element after code[n - 1] is code[0] and the element before code[0] is code[n - 1].
Return the decrypted code.