You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array
code
of length ofn
and a keyk
.To decrypt the code, you must replace every number. All the numbers are replaced simultaneously.
- If
k > 0
, replace theith
number with the sum of the nextk
numbers.- If
k < 0
, replace theith
number with the sum of the previousk
numbers.- If
k == 0
, replace theith
number with0
.As
code
is circular, the next element ofcode[n-1]
iscode[0]
, and the previous element ofcode[0]
iscode[n-1]
.Given the circular array
code
and an integer keyk
, return the decrypted code to defuse the bomb!