-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava-BigDecimal.java
More file actions
35 lines (31 loc) · 878 Bytes
/
Java-BigDecimal.java
File metadata and controls
35 lines (31 loc) · 878 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
34
35
import java.math.BigDecimal;
import java.util.*;
class Solution{
public static void main(String []args){
//Input
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,new Comparator<Object>(){
@Override
public int compare(Object s1, Object s2)
{
if(s1 == null || s2 == null)
return 0;
BigDecimal bd1 = new BigDecimal((String)s1);
BigDecimal bd2 = new BigDecimal((String)s2);
return bd2.compareTo(bd1);
}
});
//Output
for(int i=0;i<n;i++)
{
System.out.println(s[i]);
}
}
}