map无脑过

子串计算

https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

string str;
map<string, int> tree_map;

int main()
{
    cin >> str;

    for (int i = 0; i < str.size(); ++i)
        for (int j = i; j < str.size(); ++j)
        {
            string t = str.substr(i, j - i + 1);
            tree_map[t]++;
        }
    
    for (auto [u, v] : tree_map)
        if (v > 1)
            cout << u << ' ' << v << endl;
    return 0;
}

全部评论

相关推荐

05-09 12:23
已编辑
华南理工大学 Java
野猪不是猪🐗:给他装的,双九+有实习的能看的上这种厂我直接吃⑨✌们拿它练练面试愣是给他整出幻觉了
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

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