class Solution {
public:
int maxNumberOfBalloons(string text) {
vector<int> count(5,0);
for(auto i:text) {
switch(i) {
case 'b': count[0]++; break;
case 'a': count[1]++; break;
case 'l': count[2]++; break;
case 'o': count[3]++; break;
case 'n': count[4]++; break;
}
}
count[2]=count[2]/2;
count[3]=count[3]/2;
sort(count.begin(),count.end());
return count[0];
}
};
Leetcode1189(力扣1189):气球的最大数量
最新推荐文章于 2024-07-25 11:27:31 发布