6909. Longest Even Odd Subarray With Threshold
You are given a 0-indexed integer array
numsand an integerthreshold.Find the length of the longest subarray of
numsstarting at indexland ending at indexr(0 <= l <= r < nums.length)that satisfies the following conditions:
nums[l] % 2 == 0- For all indices
iin the range[l, r - 1],nums[i] % 2 != nums[i + 1] % 2- For all indices
iin the range[l, r],nums[i] <= thresholdReturn 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 { |