Skip to content

Commit

Permalink
Update 2910.Minimum-Number-of-Groups-to-Create-a-Valid-Assignment.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Nov 25, 2023
1 parent ad9d04c commit 79b55aa
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ class Solution {
public:
int minGroupsForValidAssignment(vector<int>& nums)
{
int n = nums.size();
int m = 0;
unordered_map<int,int>Map;
for (int x: nums)
{
Map[x]++;
m = max(m, Map[x]);
}
int n = nums.size();
unordered_map<int,int>Map;
for (int x: nums) Map[x]++;

int m = INT_MAX;
for (auto [_, x]: Map)
m = min(m, x);

for (int k=m; k>=1; k--)
{
Expand Down

0 comments on commit 79b55aa

Please sign in to comment.