-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathSolution.java
More file actions
33 lines (30 loc) · 903 Bytes
/
Solution.java
File metadata and controls
33 lines (30 loc) · 903 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
import java.math.BigDecimal;
import java.util.*;
class Solution {
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String[] s = new String[n + 2];
for (int i = 0; i < n; i++) {
s[i] = sc.next();
}
sc.close();
//Write your code here
Arrays.sort(s, Collections.reverseOrder(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
if (o1 != null && o2 != null) {
BigDecimal d1 = new BigDecimal(o1);
BigDecimal d2 = new BigDecimal(o2);
return d1.compareTo(d2);
}
return 0;
}
}));
//Output
for(int i = 0; i < n; i++)
{
System.out.println(s[i]);
}
}
}