Let the Balloon Rise HDU - 1004
题目链接:
题目:
题目描述
有多种颜色的气球,统计它们的个数,并找出数量最多的那种颜色。
Input 有多组样例输入。每组样例第一行输入一个整数N (0 < N <= 1000) -- 代表一共有N个气球。接下来N行每行输入一个不多于15个字母的字符串代表颜色。
N=0代表输入结束。 Output每组样例数据输出数量最多的那种颜色的气球。(保证输出唯一)
Sample Input5greenredblueredred3pinkorangepink0Sample Output
redpink 思路:比较简单的是map写法,记录字符串对应的个数,而且还是自动排序的:
//// Created by hanyu on 2019/4/9.//#include#include #include #include #include #include #include #include #include
另一种写法是我今天写的字典树的写法,也比较方便
// // Created by HJYL on 2019/8/19.//#include#include #include