Computer Science, asked by ANKITRAI863, 10 months ago

Given an array of size n and the n elements of the array. A value k is given. Find the number of sub-arrays with product of the sub-array less than or equal to the given value k

Answers

Answered by Anonymous
0

Input : arr[] = [1, 2, 3, 4]

K = 10

Output : 7

The subarrays are {1}, {2}, {3}, {4}

{1, 2}, {1, 2, 3} and {2, 3}

Input : arr[] = [1, 9, 2, 8, 6, 4, 3]

K = 100

Output : 16

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

One naive approach to this problem is to generate all subarrays of the array and then count the number of arrays having product greater than K.

Below is the implementation of above approach.

PLEASE MAKE ME AS A BRAINLIST ANSWER

Similar questions