Company: Ibm_4_Jan
Difficulty: medium
Subarray Product Equals K Problem Description Given an array of integers, calculate the total number of subarrays whose product of elements equals k . Note: The subarrays may overlap. For example, there are two subarrays whose product is 6 in [2, 3, 2] : [2, 3] and [3, 2] . Examples Example 1: Input: nums = [2, 3, 2, 2], k = 4 Output: 1 Explanation: There is only one subarray, [2, 2] (following 0-based indexing), whose product is 4. Example 2: Input: nums = [5, 2, 2, 2, 4], k = 6 Output: 0 Explanation: There is no subarray whose product of elements is 6. Constraints 0 ≤ n ≤ 2 * 10 5 , where n is the length of nums . 2 ≤ nums[i] ≤ 10 6 0 ≤ k ≤ 10 9 Function Signature The function you need to complete has the following signature: class Solution { /** * @param nums An array of integers. * @param k An integer. * @return The total number of subarrays whose product equals k. */ public long computeCount(List<Integer> nums, int k) { // Write your code here } }