NeetCode #145LC-2870MediumArrays & Hashing
← Back to All Problems#145 · #2870 · Minimum Number of Operations to Make Array Empty(使数组为空的最少操作次数)
📌 Problem Statement & Constraints
You are given an array
nums of positive integers. In one operation, remove either two equal elements or three equal elements. Return the minimum number of operations to empty the array, or -1 if it is impossible. Constraints: 2 <= nums.length <= 10^5, 1 <= nums[i] <= 10^6.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!