32. The array of aligned smallest number (Python)

Title Description

Enter a positive integer array, the array of all the numbers arranged in a number spliced ​​together, the splice can print out all numbers smallest one. 3,32,321 input array} {e.g., print the minimum number of three numbers can be arranged to 321,323.
1 # -*- coding:utf-8 -*-
2 class Solution:
3     def PrintMinNumber(self, numbers):
4         # write code here
5         lamb = lambda n1,n2 : int(str(n1)+str(n2))-int(str(n2)+str(n1))
6         numbers=sorted(numbers,lamb)
7         return ''.join([str(i) for i in numbers])

2019-12-21 21:28:38

Guess you like

Origin www.cnblogs.com/NPC-assange/p/12078306.html