华为-2022-08-02-ai搜索岗一面二面

https://leetcode.cn/problems/most-common-word/

https://leetcode.cn/problems/the-number-of-the-smallest-unoccupied-chair/

原题

#include 
#include 
#include 
#include 

using namespace std;

int main()
{
    string paragraph;
    unordered_map wordCount;
    unordered_set banned;
    banned.insert("hit");
    // cin >> paragraph;
    paragraph = "Bob hit a ball, the hit BALL flew far after it was hit.";

    int n = paragraph.length();
    int maxCount = 0;
    string maxCountString;

    for (int i = 0; i < n;)
    {
        int j = i;
        string word = "";
        while (j < n && isalpha(paragraph[j]))
        {
            // char c = (paragraph[j]>='A' && paragraph[j]<='Z') ? paragraph[j]+32:paragraph[j];
            // cout<<paragraph[j]<<", "<<c<<"\n";
            word.append(string(1,tolower(paragraph[j])));
            j++;
        }

        wordCount[word]++;

        while (j < n && !isalpha(paragraph[j]))
            j++;
        i = j;
    }

    for (auto &[word, cnt] : wordCount)
    {
        if (cnt > maxCount&&banned.count(word)==0)
        {
            maxCount = cnt;
            maxCountString = word;
        }
    }

    cout<<maxCountString<<"\n";

    return 0;
}
#华为面试##面试##秋招#
全部评论

相关推荐

10-29 16:42
门头沟学院 Java
1.今天什么国标的公司打电话约面试,还得准备ppt,好麻烦,网上查薪资一般,打算拒了,不面了2.字节又复活了,什么安全开发,也不知道怎么样,面一面试试吧,还是挺想去字节的,但好难,随缘吧所以今天没面试
嵌入式的小白:面试前可以好好准备下 1.看看你投递的岗位的岗位描述,分析下是哪个业务线,同使要罗列他们描述中提到的技术点 2.根据1中的两点准备 3.岗位描述中应该还有语言要求,这个刷刷八股,要是对自己语言能力很有把握,那就不用看这点了 4.找下你简历中项目部分,看有没有和岗位描述中技术点重合的,这种在面试提到项目时,是高概率问题 好好准备,祝你面试顺利
我的求职进度条
点赞 评论 收藏
分享
09-19 12:15
门头沟学院 Java
迷茫的大四🐶:这下是真的打牌了,我可以用感谢信和佬一起打牌吗
点赞 评论 收藏
分享
评论
点赞
4
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务