Steward
分享是一種喜悅、更是一種幸福
程式語言 - LeetCode - C++ - 1189. Maximum Number of Balloons
題目:

解答:
class Solution {
public:
int maxNumberOfBalloons(string text) {
vector cnt(26, 0);
for (char ch : text) {
cnt[ch - 'a'] += 1;
}
return min({
cnt['b' - 'a'],
cnt['a' - 'a'],
cnt['l' - 'a'] >> 1,
cnt['o' - 'a'] >> 1,
cnt['n' - 'a']
});
}
};