You are given a nums and an integer k.
In one operation, you can choose any index i and either increment or decrement nums[i] by
The array nums is called modulo alternating if there exist two distinct integers x and y such that:
x, y
x y
nums[i] % k == x for all even indices i
nums[i] % k == y for all odd indices i
Return the minimum number of operations needed to make nums modulo alternating.
Constraints:
nums.length
nums[i]
k
You are given a nums and an integer k.
In one operation, you can choose any index i and either increment or decrement nums[i] by
The array nums is called modulo alternating if there exist two distinct integers x and y such that:
x, y
x y
nums[i] % k == x for all even indices i
nums[i] % k == y for all odd indices i
Return the minimum number of operations needed to make nums modulo alternating.
Constraints:
nums.length
nums[i]
k