Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make Array Beautiful

Minimum Deletions to Make Array Beautiful asks you to remove as few values as possible so the remaining array has even length and no equal adjacent pair at an even position.

Statement

You are given a 00 indexed integer array nums.

An array is considered beautiful if it satisfies the following conditions:

  • The length of the array is even.

  • For every even index i such that 0≤i<0 \leq i < nums.length −1- 1, nums[i] != nums[i + 1].

You may delete any number of elements from nums. Whenever an element is deleted, all elements to its right shift to the left by 11 position, and the length of the array decreases by 11.

Return the minimum number of elements that must be deleted from nums to make it beautiful.

Constraints:

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make Array Beautiful

Minimum Deletions to Make Array Beautiful asks you to remove as few values as possible so the remaining array has even length and no equal adjacent pair at an even position.

Statement

You are given a 00 indexed integer array nums.

An array is considered beautiful if it satisfies the following conditions:

  • The length of the array is even.

  • For every even index i such that 0≤i<0 \leq i < nums.length −1- 1, nums[i] != nums[i + 1].

You may delete any number of elements from nums. Whenever an element is deleted, all elements to its right shift to the left by 11 position, and the length of the array decreases by 11.

Return the minimum number of elements that must be deleted from nums to make it beautiful.

Constraints:

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

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