Back to course home
0% completed
Subarrays with Product Less than a Target (medium)
Problem Statement
Given an array with positive numbers and a positive target number, find all of its contiguous subarrays whose product is less than the target number.
Example 1:
Input: [2, 5, 3, 10], target=30
Output: [2], [5], [2, 5], [3], [5, 3], [10]
Explanation: There are six contiguous subarrays whose product is less than the target.
Example 2:
Input: [8, 2, 6, 5], target=50
Output: [8], [2], [8, 2], [6], [2, 6], [5], [6, 5]
Explanation: There are seven contiguous subarrays whose product is less than the target.
Constraints:
1 <= arr.length <= 3 * 104
1 <= arr[i] <= 1000
0 <= k <= 106
Try it yourself
Try solving this question here:
Python3
Python3
. . .
Mark as Completed