Tap here to switch tabs
Problem
Submissions

Problem: Longest Alternating Subarray After One Removal

Longest Alternating Subarray After One Removal asks for the maximum length of a contiguous subarray after removing at most one element, with adjacent values switching between strict rises and falls.

Statement

Given an integer array nums, you can remove at most 11 element from the array.

An array is considered alternating if its length is 11, or if every adjacent pair of elements alternates strictly between increasing and decreasing relations (either nums[0] < nums[1] > nums[2] < nums[3] ... or nums[0] > nums[1] < nums[2] > nums[3] ...).

Return the maximum length of an alternating contiguous subarray you can obtain after removing at most 11 element.

Constraints:

  • 2≤2 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Alternating Subarray After One Removal

Longest Alternating Subarray After One Removal asks for the maximum length of a contiguous subarray after removing at most one element, with adjacent values switching between strict rises and falls.

Statement

Given an integer array nums, you can remove at most 11 element from the array.

An array is considered alternating if its length is 11, or if every adjacent pair of elements alternates strictly between increasing and decreasing relations (either nums[0] < nums[1] > nums[2] < nums[3] ... or nums[0] > nums[1] < nums[2] > nums[3] ...).

Return the maximum length of an alternating contiguous subarray you can obtain after removing at most 11 element.

Constraints:

  • 2≤2 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5