-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayMaxNumber.java
More file actions
30 lines (28 loc) · 889 Bytes
/
ArrayMaxNumber.java
File metadata and controls
30 lines (28 loc) · 889 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
package Ds.Achievers;
import java.util.*;
public class ArrayMaxNumber {
public static void main(String[] args) {
Vector<String> vector = new Vector<>();
System.out.println("enter number of elements");
Scanner sc = new Scanner(System.in);
int size = sc.nextInt();
for (int i = 0 ; i < size ; i++){
vector.add(sc.next());
}
maxNumber(vector);
}
static void maxNumber(Vector<String> vector){
Collections.sort(vector, new Comparator<String>() {
@Override
public int compare(String a, String b) {
String ab = a + b;
String ba = b + a;
return ab.compareTo(ba) > 0 ? -1 : 1;
}
});
Iterator itr = vector.iterator();
while (itr.hasNext()){
System.out.print(itr.next());
}
}
}