-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy path31.py
More file actions
36 lines (26 loc) · 617 Bytes
/
31.py
File metadata and controls
36 lines (26 loc) · 617 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding:utf-8 -*-
def cmp(str1, str2):
s1 = str1 + str2
s2 = str2 + str1
if int(s1) < int(s2):
return -1
else:
return 0
class Solution:
def PrintMinNumber(self, numbers):
# write code here
if numbers is None:
return ""
if len(numbers) == 0:
return ""
strs = []
for item in numbers:
strs.append(str(item))
strs.sort(cmp)
print strs
r = ''
for item in strs:
r = r + item
return int(r)
s = Solution()
print s.PrintMinNumber([3, 5, 1, 4, 2])