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;
    }
全部评论

相关推荐

飞花断音:这个头像有点搞笑
点赞 评论 收藏
分享
被普调的六边形战士很高大:项目经历貌似和专业或者求职方向没大关系?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务