C++,代码简洁,自定义排序规则

拼接所有的字符串产生字典序最小的字符串

http://www.nowcoder.com/practice/f1f6a1a1b6f6409b944f869dc8fd3381

string minString(vector<string>& strs) {
        // write code here
        sort(strs.begin(), strs.end(), [](const string &a,const string& b){
            return (a+b)<(b+a);
        });
        string res;
        for (const auto& str : strs) {
            res += str;
        }
        return res;
    }
全部评论

相关推荐

06-27 15:15
长安大学 Java
哈哈哈,你是老六:这种就是培训机构骗钱的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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