题解 | #后缀子串排序#

后缀子串排序

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<string> strs;

int main() {
    string str;
    cin >> str;
    for(int i = 0; i < str.length(); i ++){
        strs.push_back(str.substr(i));//调用substr函数获取所有子串
    }
  	//调用sort函数
    sort(strs.begin(), strs.end());
    for(string s : strs){
        cout << s << endl;
    }
    return 0;
}

全部评论

相关推荐

前两题写得快,最后一题也只会个暴力,结束笔试
洛水为天依:第三题卡在了71%,实在看不出来错哪了直接交卷了
投递米哈游等公司10个岗位
点赞 评论 收藏
分享
头像
09-01 09:00
已编辑
四川旅游学院 运营
牛客55195891...:主要是专业不好,别的没毛病
牛客解忧铺
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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