Example 1
Input
4 1
1 2 3 4Output
3 5 7 5Transform 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.
4 1
1 2 3 43 5 7 54 1
1 2 3 43 5 7 5