Grokking Google Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Adam Slowik
lower space complexity than in suggesgted answer

Adam Slowik

Dec 13, 2025

public int minArrayLength(int[] nums, int k) { // ToDo: Write Your Code Here. int counter = 0; int currentProduct = nums[0]; for (int i = 1; i < nums.length; i++) { if (nums[i] == 0){ return 1; } currentProduct *= nums[i]; if (currentProduct <= k) { counter++; } else { currentProduct = nums[i]; } } return nums.length - counter; }

0

0

Comments
Comments