leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2870.cpp (362B)


0 class Solution {
1 public:
2 int minOperations(const vector<int> &nums) const {
3 unordered_map<int, int> count;
4 for (const int n : nums)
5 count[n]++;
7 int res = 0;
8 for (const auto [_, cnt] : count) {
9 if (cnt == 1) return -1;
10 res += ceil((double)cnt / 3);
11 }
12 return res;
13 }
14 };