Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
kat h
Why is the output=0 if k=1?

kat h

Jan 27, 2025

Since the numbers of the array nums are positive integers, I expected k=1 to possibly return >0. However, in the solution, when k=1, output was 0.

0

0

Comments
Comments
Dillon Heins
Dillon Heins9 months ago

The question states "less than the target." Since the numbers in the array are always ≥ 1, any combination of numbers in the array will result in a product that is at least 1. Therefore, it is impossible to have any subarray with a product less than 1, w...