← ALL NOTES
LeetCode

3524. Find X Value of Array I

Bucket every subarray by its product mod k in one left-to-right sweep. Keep a k-sized residue distribution per right endpoint; extend by (r*a)%k and add the singleton. O(n*k) with k<=5.

Loading…