MOD
for the modulo operation.nums
array and store it in a variable dividingPoint
.prefix
to store prefix sums for step sizes up to dividingPoint
.y
up to dividingPoint
and for each possible starting point.[x, y]
.y
is greater than dividingPoint
, compute the sum on the fly by iterating from x
to the end of nums
, incrementing by y
each time.y
is less than or equal to dividingPoint
, use the precomputed prefix sum to find the answer in constant time.res
list after applying the modulo operation.res
list.