Tap here to switch tabs
Problem
Submissions

Problem: Maximum Equal Adjacent Pairs After One Replacement

Maximum Equal Adjacent Pairs After One Replacement asks you to change every occurrence of one value to another at most once, then return the greatest number of adjacent equal pairs in the array.

Statement

You are given an integer array nums.

You are permitted to perform the following operation at most 11 time:
Select two integers x and y, and replace every element in nums that is equal to x with y.

Return the maximum number of adjacent equal pairs (indices i satisfying nums[i] == nums[i + 1]) that can be obtained after applying at most 11 operation.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Equal Adjacent Pairs After One Replacement

Maximum Equal Adjacent Pairs After One Replacement asks you to change every occurrence of one value to another at most once, then return the greatest number of adjacent equal pairs in the array.

Statement

You are given an integer array nums.

You are permitted to perform the following operation at most 11 time:
Select two integers x and y, and replace every element in nums that is equal to x with y.

Return the maximum number of adjacent equal pairs (indices i satisfying nums[i] == nums[i + 1]) that can be obtained after applying at most 11 operation.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9