1、题目描述

2、 将整数值转换为string  ,然后排序。

3、代码

 string largestNumber(vector<int>& nums) {
vector<string> s;
for( auto n : nums){
s.push_back(to_string(n));
} sort( begin(s), end(s) , [](string &s1 , string s2){ return s1 + s2 < s2 + s1;});
string res ;
for(vector<string>::reverse_iterator it = s.rbegin() ; it != s.rend(); ++it){
res += *it;
}
if( res.front() == '')
res = "";
return res; }

LeetCode题解之Largest Number的更多相关文章

  1. [LeetCode 题解]:Palindrome Number

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Determine ...

  2. 【Leetcode】179. Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  3. LeetCode 179. 最大数(Largest Number) 21

    179. 最大数 179. Largest Number 题目描述 给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数. 每日一算法2019/5/24Day 21LeetCode179. La ...

  4. [leetcode sort]179. Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  5. LeetCode OJ:Largest Number(最大数字)

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  6. 【LeetCode #179】Largest Number 解题报告

    原题链接:Largest Number 题目描述: Given a list of non negative integers, arrange them such that they form th ...

  7. 【刷题-LeetCode】179 Largest Number

    Largest Number Given a list of non negative integers, arrange them such that they form the largest n ...

  8. 【LeetCode】747. Largest Number At Least Twice of Others 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 寻找两次最大值 排序 大顶堆 日期 题目地址:htt ...

  9. 《LeetBook》leetcode题解(9):Palindrome Number[E]——回文数字

    我现在在做一个叫<leetbook>的开源书项目,把解题思路都同步更新到github上了,需要的同学可以去看看 地址:https://github.com/hk029/leetcode 这 ...

随机推荐

  1. 《CEO说 像企业家一样思考》读书笔记

    伟大的CEO和街头小贩一样都有共同的思维方式,他们总是能够通过复杂的表象看到商业本质,化繁为简,抓住企业经营的根本要素:商业智慧.所谓商业智慧,即企业家最应关注的企业运营的六个关键要素:现金净流入.利 ...

  2. react项目中使用antd

    1.antd官网: https://ant.design/docs/react/introduce-cn 2.React中使用Antd 1.安装antd npm install antd --save ...

  3. VMware12 克隆虚拟机并且重新分配ip、mac

    记录如何快速拷贝一台虚拟机,并且重新分配IP.mac等方便自己做实验: 环境:VMWare12  .Redhat6.8 Step1.克隆虚拟机 虚拟机处于未打开状态,右击管理—>克隆 弹出克隆界 ...

  4. console 调试技巧

    前言 如果统计一番前端最常用的方法,那么 console.log 一定位列其中.无论你写的是原生 JS 亦或者是 JQuery.Vue等等,调试之时,都离不开 console.log 方法.但是,co ...

  5. springboot 单体架构之shiro集成

    这里使用的是eclipse 开发工具 1.springboot 版本是2.0的,引入了2个shiro 的依赖,如下 <parent> <groupId>org.springfr ...

  6. asp.net mvc 学习笔记 - 单一实例设计模式

    学习之前,先喊一下口号:每天进步一点,生活更好一点 首先声明一点,我也是新新新手一枚,崭新的新哦.如果文章有不合理的地方,也请各位博友多多指点,不要乱喷哦 我的文采很低调,低调到语文老师对我的期望是你 ...

  7. 公众号开发之wx-tools+springboot应用实战-音乐爬虫推送[JAVA]

    springboot+wx-tools实践!音乐爬虫推送公众号DEMOGitHub地址:wx-tools 最终DEMO源码地址: music_collector 先理一下大概的开发步骤: 1. 创建一 ...

  8. 装饰者模式的学习(c#)

    案例转自https://www.cnblogs.com/stonefeng/p/5679638.html //主体基类 using System;using System.Collections.Ge ...

  9. More Effective C++ 35 条款

    一.基础议题(basics) 条款1:仔细区别 pointers 和 references(Distinguish between pointers and references) 一个基本的语法问题 ...

  10. 撩课-Web大前端每天5道面试题-Day27

    1.浏览器缓存? 浏览器缓存分为强缓存和协商缓存.当客户端请求某个资源时,获取缓存的流程如下: 先根据这个资源的一些 http header 判断它是否命中强缓存, 如果命中,则直接从本地获取缓存资源 ...