dimanche 6 décembre 2015

How can I count the no. of subarrays that have the product of elements smaller than a number D?

How can I count the no. of subarrays that have the product of elements smaller than a number D without counting the empty subarray ?

For example :

array=[2,2,2,3,4,10] D=50 The answer should be 39. I tried with backtracking, but it's not so faster. All number in the array are smaller or equal with D and bigger than 0.

Aucun commentaire:

Enregistrer un commentaire