NumSubarrayProductLessThanK { public int numSubarrayProductLessThanK(int[] nums, int k) { if (k < 1) return 0; int product = 1, left = -1, n = 0; for (int i = 0; i < nums.length; i++) { product *= nums[i]; while (left < i && product >= k) product /= nums[++left]; n += i - left; } return n; }  int numSubarrayProductLessThanK(int[] nums, int k);  }
@Test(dataProvider = "arrayProduct") public void test(int[] array, int k, int expectedNum) { assertEquals(new NumSubarrayProductLessThanK().numSubarrayProductLessThanK(array, k), expectedNum); }