The Question
Coding
Subarray Product Less Than K
Given an array of positive integers `nums` and an integer `k`, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than `k`. Optimize for $O(n)$ time complexity and $O(1)$ space complexity.
Java
Sliding Window
Two Pointers
March 8, 2026