Skip to content

Commit 5af2d30

Browse files
committed
Solution as on 22-02-2022 08:20 pm
1 parent 9f1f70a commit 5af2d30

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// 1941.✅ Check if All Characters Have Equal Number of Occurrences
2+
3+
class Solution
4+
{
5+
public:
6+
bool areOccurrencesEqual(string s)
7+
{
8+
map<char, int> m;
9+
10+
for (auto c : s)
11+
++m[c];
12+
13+
int a = m[s[0]];
14+
15+
for (auto i : m)
16+
{
17+
if (a != i.second)
18+
return false;
19+
}
20+
21+
return true;
22+
}
23+
};

0 commit comments

Comments
 (0)