Tap here to switch tabs
Problem
Submissions

Problem: Maximum Equal Adjacent Pairs After One Replacement

Try to solve the Maximum Equal Adjacent Pairs After at Most One Replacement problem.

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

Try to solve the Maximum Equal Adjacent Pairs After at Most One Replacement problem.

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