Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 1941. Check if All Characters Have Equal Number of Occurrences

Posted on 2021-07-25 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public:
bool areOccurrencesEqual(string s) {
int c[26] = {0};
for (char ch : s) ++c[ch - 'a'];
int m = 0;
for (int x : c)
if (x) {
m = max(m, x);
if (m != x) return false;
}
return true;
}
};
# String
LeetCode 1736. Latest Time by Replacing Hidden Digits
LeetCode 1942. The Number of the Smallest Unoccupied Chair
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%