problem

937. Reorder Log Files

solution:

class Solution {
public:
vector<string> reorderLogFiles(vector<string>& logs) {
vector<string> letterlogs, digitlogs;
for(auto log:logs)
{
int i=log.find(' ');
if(isdigit(log[i+])) digitlogs.push_back(log);
else letterlogs.push_back(log);
}
sort(letterlogs.begin(), letterlogs.end(),
[](string a, string b)
{
int i = a.find(' ');
int j = b.find(' ');
if(a.substr(i+) == b.substr(j+)) return a.substr(, i-) < b.substr(, j-);//err....
return a.substr(i+) < b.substr(j+);
});//err...
letterlogs.insert(letterlogs.end(), digitlogs.begin(), digitlogs.end());
return letterlogs; }
};

参考

1. Leetcode_easy_937. Reorder Log Files;

2. discuss1_conpare;

3. discuss2_sort;

4. discuss3_moveback;

完

【Leetcode_easy】937. Reorder Log Files的更多相关文章

  1. 【leetcode】937. Reorder Log Files

    题目如下: You have an array of logs.  Each log is a space delimited string of words. For each log, the f ...

  2. 【LeetCode】937. Reorder Log Files 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 分割和排序 日期 题目地址:https://leet ...

  3. LeetCode 937 Reorder Log Files 解题报告

    题目要求 You have an array of logs.  Each log is a space delimited string of words. For each log, the fi ...

  4. leecode 937 Reorder Log Files (模拟)

    传送门:点我 You have an array of logs.  Each log is a space delimited string of words. For each log, the ...

  5. 937. Reorder Log Files

    You have an array of logs.  Each log is a space delimited string of words. For each log, the first w ...

  6. 【LeetCode】143. Reorder List 解题报告(Python)

    [LeetCode]143. Reorder List 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...

  7. LeetCode.937-重新排序日志数组(Reorder Log Files)

    这是悦乐书的第358次更新,第385篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第220题(顺位题号是937).你有一系列日志.每个日志都是以空格分隔的单词串. 每个日 ...

  8. 【LeetCode】Reorder Log Files(重新排列日志文件)

    这道题是LeetCode里的第937道题. 题目描述: 你有一个日志数组 logs.每条日志都是以空格分隔的字串. 对于每条日志,其第一个字为字母数字标识符.然后,要么: 标识符后面的每个字将仅由小写 ...

  9. 【tomcat】FileNotFoundException: C:\Program Files\Java\apache-tomcat-8.5.11-geneshop3\webapps\ROOT\index.html (拒绝访问。)

    新装系统后,tomcat启动起来 提示如下错误: Caused by: java.io.FileNotFoundException: C:\Program Files\Java\apache-tomc ...

随机推荐

  1. [Schematics] 1. Copy and Manipulate Template

    1. Create a src/my-component/files/src/app directory to hold your templates. mkdir -p src/my-compone ...

  2. JS AJAX和JSONP的基础功能封装以及使用示例;

    1.代码: function ajax(options){ options = options || {}; options.type = options.type || "get" ...

  3. XOR Clique(按位异或)

    XOR Clique(按位异或): 传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4057 准备:异或:参加运算的两 ...

  4. 《挑战30天C++入门极限》C++类对象的复制-拷贝构造函数

        C++类对象的复制-拷贝构造函数 在学习这一章内容前我们已经学习过了类的构造函数和析构函数的相关知识,对于普通类型的对象来说,他们之间的复制是很简单的,例如: int a = 10; int ...

  5. phpstorm 2019.1 修改浏览器

    如图,修改如下浏览器的位置,由于我安装了虚拟机,导致每次点击谷歌浏览器后,都是打开的虚拟机里面的谷歌浏览器,需要重新设置浏览器的位置 打开设置 打开浏览器设置界面 双击可以选择浏览器的路径,然后就可以 ...

  6. 【洛谷】P3177 [HAOI2015]树上染色

    懒得复制题面了直接传送门吧 分析 直接求点与点之间的距离感觉不是很好求,所以我们考虑换一个求法. 瞄了一眼题解 距离跟路径上边的长度有关,所以我们直接来看每一条边的贡献吧(这谁想得到啊) 对于每一条边 ...

  7. input的禁止标签

    <body> <input type="text" name="" value="你好" disabled="d ...

  8. return关键字

    注意:如果一个函数的返回值类型是具体的数据类型,那么该函数就必须要保证在任意情况下都保证有返回值(除了返回值类型是void)     return  关键字的作用: 1   返回数据给函数的调用者. ...

  9. c和s标签

    <s:if test="#request.iflag=='fj'"> <a title="复检录入" href="javascrip ...

  10. web开发学习的网站

    网易云课堂>imooc>coursera   网易云课堂 imooc.com 关于web的视频会多一些 最近要学一个付费的课程   http://www.v2ex.com/t/154242 ...