Skip to content

Commit dc6e4e5

Browse files
committed
Time: 521 ms (39.98%), Space: 103.6 MB (72.00%) - LeetHub
1 parent cc0d6d9 commit dc6e4e5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
public:
3+
int minimumRounds(vector<int>& tasks) {
4+
5+
unordered_map<int,int> mp;
6+
7+
int ans = 0;
8+
9+
for(auto itr : tasks)
10+
++mp[itr];
11+
12+
for(auto itr : mp)
13+
{
14+
if(itr.second == 1)
15+
return -1;
16+
else if(itr.second % 3 == 0)
17+
ans += itr.second/3;
18+
else
19+
ans += itr.second/3 + 1;
20+
}
21+
22+
return ans;
23+
}
24+
};

0 commit comments

Comments
 (0)