- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
Latest commit
27 lines (24 loc) · 798 Bytes
/
Copy pathSolution.java
File metadata and controls
27 lines (24 loc) · 798 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
importjava.math.BigDecimal;
importjava.util.Arrays;
importjava.util.Collections;
importjava.util.Scanner;
publicclassSolution {
publicstaticvoidmain(String[] args) {
try (Scannersc = newScanner(System.in)) {
intn = sc.nextInt();
String[] s = newString[n + 2];
for (inti = 0; i < n; i++) {
s[i] = sc.next();
}
Arrays.sort(s, Collections.reverseOrder((o1, o2) -> {
if (o1 == null || o2 == null) return0;
BigDecimalbd1 = newBigDecimal(o1);
BigDecimalbd2 = newBigDecimal(o2);
returnbd1.compareTo(bd2);
}));
for (Stringnum : s) {
System.out.println(num);
}
}
}
}