Tap here to switch tabs
Problem
Submissions

Problem: Longest Even Odd Subarray With Threshold

med
30 min
Try to solve the Longest Even Odd Subarray With Threshold problem.

Statement

You are given a 00 indexed integer array nums and an integer threshold.

Find the maximum length of a contiguous subarray starting at index l and ending at index r (l≤rl \leq r) that satisfies the following conditions:

  • nums[l] % 2=02 = 0

  • nums[i] % 2≠2 \neq nums[i + 11] % 22 for every index ii where l≤i<rl \leq i < r

  • nums[i] \leq threshold for every index ii where l≤i≤rl \leq i \leq r

Return the length of the longest subarray that meets these conditions, or 00 if no such subarray exists.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq threshold ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Even Odd Subarray With Threshold

med
30 min
Try to solve the Longest Even Odd Subarray With Threshold problem.

Statement

You are given a 00 indexed integer array nums and an integer threshold.

Find the maximum length of a contiguous subarray starting at index l and ending at index r (l≤rl \leq r) that satisfies the following conditions:

  • nums[l] % 2=02 = 0

  • nums[i] % 2≠2 \neq nums[i + 11] % 22 for every index ii where l≤i<rl \leq i < r

  • nums[i] \leq threshold for every index ii where l≤i≤rl \leq i \leq r

Return the length of the longest subarray that meets these conditions, or 00 if no such subarray exists.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq threshold ≤100\leq 100