Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Operations to Make Array Empty

med
30 min
Try to solve the Minimum Number of Operations to Make Array Empty problem.

Statement

You are given a 00 indexed array nums consisting of positive integers.

You can perform two types of operations on the array any number of times:

  • Choose 22 elements with equal values and remove them from the array.

  • Choose 33 elements with equal values and remove them from the array.

Return the minimum number of operations required to make the array empty, or −1-1 if it is impossible to empty the array.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Operations to Make Array Empty

med
30 min
Try to solve the Minimum Number of Operations to Make Array Empty problem.

Statement

You are given a 00 indexed array nums consisting of positive integers.

You can perform two types of operations on the array any number of times:

  • Choose 22 elements with equal values and remove them from the array.

  • Choose 33 elements with equal values and remove them from the array.

Return the minimum number of operations required to make the array empty, or −1-1 if it is impossible to empty the array.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6