【Leetcode】| Largest Number
问题描述
Given a list of non negative integers, arrange them such that they form the largest number.
- 给定一个非负整数的列表,把它们排列成最大的数。
实例
For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.
- 例如: 列表[3, 30, 34, 5, 9],组成的最大数为 9534330.
注意事项
Note: The result may be very large, so you need to return a string instead of an integer.
- 注意:结果可能非常大,因此需要返回一个字符串而不是整形数。
代码
def largestNum(nums):nums = sorted([str(i) for i in nums], cmp=lambda x, y: cmp(y + x, x + y))return "".join(nums).lstrip() or '0'print largestNum([3, 30, 34, 5, 9])
【Leetcode】| Largest Number相关推荐
- 【Leetcode】Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 思路:若使用[Leetcode]Reverse I ...
- 【LeetCode】Palindrome Number(回文数)
这道题是LeetCode里的第9道题. 题目说的: 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 2: ...
- 【LeetCode】191. Number of 1 Bits
题目: Write a function that takes an unsigned integer and returns the number of '1' bits it has (also ...
- 【leetcode】Single Number (Medium) ☆
题目: Given an array of integers, every element appears twice except for one. Find that single one. No ...
- 【leetcode】726. Number of Atoms
题目如下: 解题思路:我用的是递归的方法,每次找出与第一个')'匹配的'('计算atom的数量后去除括号,只到分子式中没有括号为止.例如 "K4(ON(SO3)2)2" -> ...
- leetcode【537】Complex Number Multiplication(复数相乘)
写在最前面:一道很常规的字符串分割的题 leetcode[537]Complex Number Multiplication Given two strings representing two co ...
- 【leetcode】85. Maximal Rectangle 0/1矩阵的最大全1子矩阵
1. 题目 Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1 ...
- 【leetcode】486. Predict the Winner
题目如下: Given an array of scores that are non-negative integers. Player 1 picks one of the numbers fro ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
- 【LeetCode】第374题——猜数字大小(难度:简单)
[LeetCode]第374题--猜数字大小(难度:简单) 题目描述 解题思路 代码详解 注意点 题目描述 猜数字游戏的规则如下: 每轮游戏,我都会从 1 到 n 随机选择一个数字. 请你猜选出的是哪 ...
最新文章
- Java 时间和日期类型的 Hibernate 映射
- 基于Matlab的声波信号处理,基于声卡和Matlab平台的语音信号增强处理系统
- Day8 Python基础之遗漏知识点(六)
- pyecharts应用3 Faker函数库
- 025 资源的隔离与配置
- php学习----运算符
- webpack中,css中打包背景图,路径报错
- 如何导入外部Git仓库到中国源代码托管平台(Git@OSC)
- Oracle ERP权限管理
- windows linux内核版本,微软决定在Windows10中发布一个完整的Linux内核
- php生成网页桌面快捷方式
- Jquery截取中文字符串
- 2012第二届GIS制图大赛——赛前培训资料(上篇)
- 微分几何笔记(1)——参数曲线、内积、外积
- 这18个网站能让你的页面背景炫酷起来
- Spring boot在线客服系统源码 在线坐席对话源码
- QT5的程序打包发布(Windows)
- RTP载荷PS流全面分析
- 内核ioremap接口报Warning问题
- fs的负载均衡 opensip+keeplive-fs
热门文章
- MyIM2006开发报告1:概要
- Virtual-Taobao: Virtualizing Real-World Online Retail Environment for Reinforcement Learning
- 数据科学家也良莠不齐 蹩脚数据科学家的10个迹象
- Kienct与Arduino学习笔记(1) 基础知识之Arduino’Kinect‘Processing
- 虚拟机配置opc服务器,组态王怎么配置成opc服务器
- 山东理工ACM 1603 Least Common Multiple
- c语言编写数码管的现实函数,C语言实现一位共阳极数码管
- java程序猿高考试卷,请注意查收!
- 现代计算机网络的前沿技术,现代计算机网络的前沿技术分析
- 聊聊游戏本推荐排行榜 这一款竟成黑马