Ouroboros
1s 11 MB
Transform the array such that every element becomes the sum of its original value and the value of the element steps ahead in the cycle.
Formally, update every element as follows:
Note: This transformation must be performed in-place with auxiliary space. The calculation for must use the values of before any updates were made.
Constraints
- All input values are integers.
Examples
Example 1
Input:
4 1
1 2 3 4Output:
3 5 7 5Accepted 5/16
Acceptance 31%
Loading editor...
Input
4 1
1 2 3 4Expected Output
3 5 7 5Custom Test Cases:
Input Expected Output