Longest Subarray
Problem Overview
- Find the maximum length of a contiguous subarray whose sum is less than or equal to k.
- Input: integer array a and integer k; Output: an integer length.
- Constraints: n up to 1e5, a[i] in 1–1e3, k up to 1e9; performance matters for large data.
- Real-world domain: array/window sum evaluation; a common coding interview problem and interview question from Goldman interviews.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
