-
Notifications
You must be signed in to change notification settings - Fork 258
/
Copy path45.java
48 lines (28 loc) · 759 Bytes
/
45.java
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
37
38
39
40
41
42
43
44
45
46
47
48
class Solution {
public String minNumber(int[] nums) {
if(nums==null||nums.length==0)
{
return " ";
}
List<Integer> list = new LinkedList<>();
for(int i=0;i<nums.length;i++)
{
list.add(nums[i]);
}
Collections.sort(list,new Comparator<Integer>(){
@Override
public int compare(Integer o1,Integer o2)
{
String s1 = o1+"" +o2;
String s2 = o2+""+o2;
return s1.compareTo(s2);
}
});
StringBuilder result = new StringBuilder();
for(int i:list)
{
result.append(i);
}
return result.toString();
}
}