Subarrays with product limit

Write codeMedium22 min

Your task

Given an array of positive integers nums and an integer k, return the number of contiguous subarrays whose product is strictly less than k. Array length up to 3e4, values >= 1.

Examples

num_subarray_product_less_than_k(nums: list[int], k: int) -> int
Example 1
Inputnum_subarray_product_less_than_k([10, 5, 2, 6], 100)
Output8