Back to course home
0% completed
Vote For New Content
Solution: Minimum Number of Operations to Make Array Empty
Problem Statement
You are given an array nums consisting of positive integers.
You can perform below two operations on the array multiple times:
- Select two elementswithequal valuesanddeletethem from the array.
- Select three elementswithequal valuesanddeletethem from the array.
Return the minimum number of operations required to make the array empty, or -1 if it is not possible.
Examples
Example 1:
- Input: nums = [1, 3, 2, 1, 2, 2, 3]
- Expected Output: 3
- Justification: We can perform the following operations:
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page