commit f1b10a603adde3e7158265b46ca5c38851e2c2c1
parent b4cb2b84000edff8d93699cde3c33998d60ad826
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Thu, 4 Jan 2024 02:32:03 +0000
Daily Problem
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2870.cpp b/Problems/2870.cpp
@@ -0,0 +1,15 @@
+class Solution {
+ public:
+ int minOperations(const vector<int> &nums) const {
+ unordered_map<int, int> count;
+ for (const int n : nums)
+ count[n]++;
+
+ int res = 0;
+ for (const auto [_, cnt] : count) {
+ if (cnt == 1) return -1;
+ res += ceil((double)cnt / 3);
+ }
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -1041,6 +1041,7 @@ for solving problems.
| 2807 | Medium | [Insert Greatest Common Divisors in Linked List](Problems/2807.cpp) |
| 2849 | Medium | [Determine if a Cell Is Reachable at a Given Time](Problems/2849.cpp) |
| 2856 | Medium | [Minimum Array Length After Pair Removals](Problems/2856.cpp) |
+| 2870 | Medium | [Minimum Number of Operations to Make Array Empty](Problems/2870.cpp) |
| 2895 | Medium | [Minimum Processing Time](Problems/2895.cpp) |
| 2900 | Medium | [Longest Unequal Adjacent Groups Subsequence I](Problems/2900.cpp) |
| 2914 | Medium | [Minimum Number of Changes to Make Binary String Beautiful](Problems/2914.cpp) |