Practice Minimum Number of Operations to Make Array Empty
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2870
LeetCode ProblemMinimum Number of Operations to Make Array Empty
Problem Statement
In one operation, remove either two equal entries or three equal entries from nums. Return the minimum operations needed to remove every entry, or -1 when this is impossible.
Source: Minimum Number of Operations to Make Array Empty on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [2,3,3,2,2,4,2,3,4]
Output
4
# Example 2
Input
nums = [2,1,2,2,3,3]
Output
-1
Constraints
2 <= nums.length <= 10^5
1 <= nums[i] <= 10^6
Related LeetCode Problems
Practice more problems similar to Minimum Number of Operations to Make Array Empty.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.