← 返回 microsoft 的题目列表Find the Maximum Length of Subarray with Sum Less Than Target
类型:online_judge
Given a non-decreasing integer array, an index, and a target value, find the maximum length of a subarray starting from the given index with a sum less than the target.
Input
array (List[int]): A non-decreasing integer array.
index (int): Starting index.
target (int): Target sum.
Output
output (int): The maximum length of the subarray.
Example
Input: array = [1, 2, 3, 4, 5], index = 0, target = 11
Output: 3
Constraints
Array length <= 10^5
Element value <= 10^4
Example
Input
5
1 2 3 4 5
0
11