6909. Longest Even Odd Subarray With Threshold
You are given a 0-indexed integer array
nums
and an integerthreshold
.Find the length of the longest subarray of
nums
starting at indexl
and ending at indexr
(0 <= l <= r < nums.length)
that satisfies the following conditions:
nums[l] % 2 == 0
- For all indices
i
in the range[l, r - 1]
,nums[i] % 2 != nums[i + 1] % 2
- For all indices
i
in the range[l, r]
,nums[i] <= threshold
Return an integer denoting the length of the longest such subarray.
Note: A subarray is a contiguous non-empty sequence of elements within an array.
1 | class Solution { |