Dsa
Arrays
Hard
Subarray Product Limit
Given an array of positive integers and a limit 'L', find the maximum length of a contiguous subarray such that the product of all its elements is less than or equal to 'L'. If no such subarray exists, return 0.
Input:
The first line contains an integer N, the number of elements in the array.
The second line contains N space-separated integers.
The third line contains the limit L, an integer.
Output:
Output a single integer, the maximum length of contiguous subarray with product less than or equal to L.
Example:
Input:
6
2 3 5 6 1 10
100
Output:
4
Key concepts
arrayssliding windowproduct
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now