1714. Sum Of Special Evenly-Spaced Elements In Array
https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array
Description
You are given a 0-indexed integer array nums
consisting of n
non-negative integers.
You are also given an array queries
, where queries[i] = [xi, yi]
. The answer to the ith
query is the sum of all nums[j]
where xi <= j < n
and (j - xi)
is divisible by yi
.
Return an array answer
where answer.length == queries.length
and answer[i]
is the answer to the ith
query modulo 109 + 7
.
Example 1:
Example 2:
Constraints:
n == nums.length
1 <= n <= 5 * 104
0 <= nums[i] <= 109
1 <= queries.length <= 1.5 * 105
0 <= xi < n
1 <= yi <= 5 * 104
ac
Last updated