Tap here to switch tabs
Problem
Submissions

Problem: Longest Alternating Subarray After One Removal

Try to solve the Longest Alternating Subarray After Removing At Most One Element problem.

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

Try to solve the Longest Alternating Subarray After Removing At Most One Element problem.

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