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. codepush安装

    https://github.com/lisong/code-push-server/blob/master/docs/README.md =====> 安装mysql下载mysql yum r ...

  2. saltstack 基础模块

    Salt 在 linux 系统下 基础操作 1.更改权限 # salt 2.更改用户 # salt '172.16.3.9' file.chown /root/test test test 3.复制文 ...

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

    介绍一下怎么安装Vue.js vue.js Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 无法模拟的 ECMAScript 5 特性. Vue.js是一个渐进的,可逐步采用的Jav ...

  4. vue-d2admin-axios异步请求登录,先对比一下Jquery ajax, Axios, Fetch区别

    先说一下对比吧 Jquery ajax, Axios, Fetch区别之我见 引言 前端技术真是一个发展飞快的领域,我三年前入职的时候只有原生XHR和Jquery ajax,我们还曾被JQuery 1 ...

  5. mapper.xml等资源导入的问题

    在pom.xml中的下导入如下字段 <resources> <resource> <directory>src/main/java</directory> ...

  6. Android 照片上传

    解释全在代码中: // 拍照上传 private OnClickListener mUploadClickListener = new OnClickListener() { public void ...

  7. redis-migrate-tool

    一.简介 redis-migrate-tool是在redis之间迁移数据的一个方便且有用的工具.他会已服务方式不断同步两边的数据.等到合适时间,中断redis读写,对比双方数据,再替换redis地址即 ...

  8. MySQL5.7授权用户远程访问

    做个记录,每次弄环境的时候,特别是弄mysql环境,时不时都要用到下面的命令 命令如下: grant all privileges on *.* to 'root'@'%' identified by ...

  9. H5注意点(1)

    H1标签在企业开发中,每一个页面至多只能有一个H1标签,被H1标签包裹的是整个页面最重要的信息. img标签,格式:<img src=" ">,当中src就是用来告诉i ...

  10. centos 普通用户 和 root 相互切换方法

    root 用户切换为普通用户 :用 login -f username (加 -f 不用输入密码)例如普通用户的用户名为hadoop,这里就是 login -f hadoop 普通用户切换为root用 ...