Algorithm · Microsoft · Medium
Given an integer array sorted in non-decreasing order, a starting position, and a target total, determine the greatest possible length of a contiguous subarray that begins at that position and whose sum is strictly below the target. Input array (List[int]): An integer array arranged in non-decreasing order. index (int): The position where the subarray must begin. target (int): The upper bound for the subarray sum. Output output (int): The largest valid subarray length.…
Checking your access…