forked from alexanderscott/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbigdecimal.java
More file actions
30 lines (25 loc) · 780 Bytes
/
Copy pathbigdecimal.java
File metadata and controls
30 lines (25 loc) · 780 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
// https://www.hackerrank.com/challenges/java-bigdecimal
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int numCases = in.nextInt();
int i = 0;
List<BigDecimal> list = new ArrayList<BigDecimal>();
while(i < numCases)
{
list.add(new BigDecimal(in.next()));
i++;
}
Collections.sort(list, Collections.reverseOrder());
for(BigDecimal d : list){
// remove leading zeros
System.out.println(d.toString().replaceAll( "^0(\\..*)$", "$1" ));
}
}
}