Tap here to switch tabs
Problem
Submissions

Problem: Longest Arithmetic Sequence After Changing One Element

Try to solve the Longest Arithmetic Sequence After Changing At Most One Element problem.

Statement

You are given an integer array nums. You may replace at most 11 element in nums with any integer.

Return the maximum length of a contiguous arithmetic subarray that can be formed after at most 11 modification.

Note: A sequence is arithmetic if the difference between consecutive elements is constant. A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 4≤4 \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 Arithmetic Sequence After Changing One Element

Try to solve the Longest Arithmetic Sequence After Changing At Most One Element problem.

Statement

You are given an integer array nums. You may replace at most 11 element in nums with any integer.

Return the maximum length of a contiguous arithmetic subarray that can be formed after at most 11 modification.

Note: A sequence is arithmetic if the difference between consecutive elements is constant. A subarray is a contiguous sequence of elements within an array.

Constraints:

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

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