题解 | #子串计算#

子串计算

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

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;cin>>s;
    map<string,int>m;
    for(int i =0;i<s.length();i++)
        for(int j =1;j<=s.length()-i;j++){
            string str = s.substr(i,j);
            // cout<<"---"<<str<<endl;
            m[str]++;
        }
    for(auto a:m)
        if(a.second>1)
            cout<<a.first<<" "<<a.second<<endl;     
}
// 64 位输出请用 printf("%lld")

暴力即可。。。还以为有什么高深算法

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 10:56
点赞 评论 收藏
分享
05-12 22:16
已编辑
北京邮电大学 研发工程师
牛客30236098...:0offer+1 滴滴都不给我面 佬没投鹅吗,鹅应该很喜欢北邮吧
投递美团等公司10个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 18:13
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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