educative.io

Educative

Is the code example for this problem correct?

I would expect an output of [2,10] as 2 x 10 < 30

Hi @Nathan,

The question is asking to find all the subarrays whose product is less than the target. A subarray, by definition, is contiguous set of elements. [2, 10] can’t be considered as a subarray, it is a subset though. See some relevant details here: https://www.hackerrank.com/challenges/java-negative-subarray/problem

Hope this clarifies your question.

3 Likes