Back to course home
0% completed
Vote For New Content
Minimum Number of Operations to Make Array Empty (medium)
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 elements
withequal values
anddelete
them from the array. - Select
three elements
withequal values
anddelete
them 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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible