#3525
Find X Value of Array II
international master · 1975 · lc hard +32 · 30.6% accepted · 30 likes · top 8%
Description
Positive integer array nums, integer k, and queries [indexi, valuei, starti, xi] are given.
For each query: first update nums[indexi] = valuei (persistent), then consider the suffix-trimmed subarray starting at starti. Count ways to further remove a (possibly empty) suffix so the product modulo k equals xi.
Return array result where result[i] is the answer for query i.
Code
1
2
3