forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
32 lines (24 loc) · 694 Bytes
/
Solution.java
File metadata and controls
32 lines (24 loc) · 694 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
class Pair implements Comparable<Pair>{
BigDecimal number;
String numberString;
Pair(BigDecimal number, String numberString) {
this.number = number;
this.numberString = numberString;
}
public int compareTo(Pair b) {
if (number.compareTo(b.number) < 0) {
return -1;
}
return 1;
}
}
ArrayList<Pair> big = new ArrayList<Pair>();
for (int i = 0; i < s.length - 2; i++) {
big.add(
new Pair(new BigDecimal(s[i]), s[i])
);
}
Collections.sort(big, Collections.reverseOrder());
for (int i = 0; i < s.length - 2; i++) {
s[i] = big.get(i).numberString;
}