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. LibreOJ #528. 「LibreOJ β Round #4」求和

    二次联通门 : LibreOJ #528. 「LibreOJ β Round #4」求和 /* LibreOJ #528. 「LibreOJ β Round #4」求和 题目要求的是有多少对数满足他们 ...

  2. 【一起来烧脑】一步学会TypeScript入门

    [外链图片转存失败(img-rmJXMGFs-1563388353181)(https://upload-images.jianshu.io/upload_images/11158618-dd813e ...

  3. (19)打鸡儿教你Vue.js

    了解vue2.x的核心技术 建立前端组件化的思想 常用的vue语法 vue-router,vuex,vue-cli 使用vue-cli工具 Vue框架常用知识点 vue核心技术 集成Vue 重点看,重 ...

  4. Linux下多线程模拟停车场停车

    #include<stdio.h> #include<string.h> #include<unistd.h> #include<stdlib.h> # ...

  5. 深度Linux /etc/profile 环境变量生效问题

    /etc/profile 环境变量生效问题 设置了环境变量后 ,使用source /etc/profile生效后,每次关闭终端后,都需要重新输入source /etc/profile命令使环境变量生效 ...

  6. Java8 LocalDateTime的补充工具方法

    import java.time.*;import java.time.format.DateTimeFormatter;import java.time.format.DateTimeFormatt ...

  7. @Autowired静态变量

    @Component public class UserUtil{ private static Config config; @Autowired public void setConfig(Con ...

  8. ciscn2019华北赛区半决赛day2_web1题解

    比赛结束以后采用非官方复现平台做的题,和比赛题有轻微不同,比赛中存放flag的table是ctf,这里是flag. 题目地址 buuoj.cn 解题过程 题目中只有一个页面,需要提交id. id为1, ...

  9. python 日期

    python datetime库使用和时间加减计算  来自:https://www.cnblogs.com/linkenpark/p/8079337.html datetime库使用 一.操作当前时间 ...

  10. 英语语法 - 介词on/in/at与时间

    介词滥用是中国学生的普遍缺点,主要是在语言学习的阶段没有人指正,形成有效的反馈,后面进入社会,就算别人发现你错了,也不会指正你,导致你一错再错. 看一篇教程,讲得不错.