-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day53.java
40 lines (31 loc) · 969 Bytes
/
Day53.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
// BigDecimal
// https://www.interviewbit.com/problems/bigdecimal/
import java.lang.*;
import java.util.*;
import java.math.BigDecimal;
public class Day53 {
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
Comparator<String> customComparator = new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
BigDecimal a = new BigDecimal(s1);
BigDecimal b = new BigDecimal(s2);
return b.compareTo(a); // descending order
}
};
Arrays.sort(s, 0, n, customComparator);
//Output
for(int i=0;i<n;i++)
{
System.out.println(s[i]);
}
}
}