Practice Minimum Deletions to Make Array Beautiful
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Delete the fewest entries from nums while preserving the remaining order so the result has even length and each pair at positions (0,1), (2,3), and so on contains different values. An empty result is valid. Return the deletion count.
Source: Minimum Deletions to Make Array Beautiful on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,1,2,3,5]
Output
1
# Example 2
Input
nums = [1,1,2,2,3,3]
Output
2
Constraints
1 <= nums.length <= 10^5
0 <= nums[i] <= 10^5
Related LeetCode Problems
Practice more problems similar to Minimum Deletions to Make Array Beautiful.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.