problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::maximum_number_of_balloons::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int maxNumberOfBalloons (const string &text)
 

详细描述

在文件 leetcode.h1076 行定义.

成员函数说明

◆ maxNumberOfBalloons()

int leetcode::maximum_number_of_balloons::Solution::maxNumberOfBalloons ( const string &  text)
static

在文件 leetcode.cpp2710 行定义.

2710 {
2711 int b = 0;
2712 int a = 0;
2713 int l = 0;
2714 int o = 0;
2715 int n = 0;
2716 for(const char ch: text) {
2717 switch(ch) {
2718 case 'b':
2719 b++;
2720 break;
2721 case 'a':
2722 a++;
2723 break;
2724 case 'l':
2725 l++;
2726 break;
2727 case 'o':
2728 o++;
2729 break;
2730 case 'n':
2731 n++;
2732 break;
2733 }
2734 }
2735 l /= 2;
2736 o /= 2;
2737 int ans = b;
2738 ans = min(ans, a);
2739 ans = min(ans, l);
2740 ans = min(ans, o);
2741 ans = min(ans, n);
2742 return ans;
2743 }

被这些函数引用 leetcode::maximum_number_of_balloons::TEST().


该类的文档由以下文件生成: