Tap here to switch tabs
Problem
Submissions

Problem: Find X Value of Array I

Find X Value of Array I asks you to count each non-empty contiguous subarray by its product modulo k, returning an array with one count for every possible value.

Statement

You are given an integer array nums and an integer k.

An operation consists of selecting a non empty contiguous subarray of nums by removing an optionally empty prefix and an optionally empty suffix. The value of the resulting subarray is the product of all its elements modulo k.

Return an array of integers of length k, where the element at index x (for 0≤x<k0 \leq x < k) represents the number of distinct operations that result in a subarray value equal to x.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤5\leq 5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find X Value of Array I

Find X Value of Array I asks you to count each non-empty contiguous subarray by its product modulo k, returning an array with one count for every possible value.

Statement

You are given an integer array nums and an integer k.

An operation consists of selecting a non empty contiguous subarray of nums by removing an optionally empty prefix and an optionally empty suffix. The value of the resulting subarray is the product of all its elements modulo k.

Return an array of integers of length k, where the element at index x (for 0≤x<k0 \leq x < k) represents the number of distinct operations that result in a subarray value equal to x.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤5\leq 5