# 22.09.2026 [3525. Find X Value of Array II]
KittyCat, Keyboard and LeetCode
0:00 / 0:00
# 22.09.2026 [3525. Find X Value of Array II]
13 просмотров · 2 дня назад
KittyCat, Keyboard and LeetCode
293 подписчика
13 просмотров · 2 дня назад
22.09.2026
[3525. Find X Value of Array II](https://leetcode.com/problems/find-x-...) hard
[substack](https://dmitriisamoilenko.substack.co...)
#### Join me on Telegram
https://t.me/leetcode_daily_unstoppab...
#### Problem TLDR
Queries of count subarrays product%k = x for x in 0..lesserk in suffixes s..end
#### Intuition
```j
// let's give up straigh from the start
// know your limits
```
Each segment tree node stores counts[product%k] and the total product for the range L..node.
Queries do query segment tree s..end and result is counts[x] of the merged query result.
To merge ranges together A[..]B[..] we taking all counts of A and we additionally taking all counts of B[i] by continuing the A[i]*i%k.
#### Approach
iterative segment tree: size 2*count, left 2*i, right 2*i+1, up i/2, query L%2bigger0, R%2bigger0 - goes horizontally+merges
#### Complexity
Time complexity:
O(nlogn)
Space complexity:
O(n)
#### Code
https://dmitrysamoylenko.com/leetcode/