Java 8 streams solution


#1

import java.util.stream.Collectors;
public class Solution {
// DO NOT MODIFY THE LIST. IT IS READ ONLY
public static String largestNumber(final List A) {
List list = A.stream().map(x -> Integer.toString(x)).collect(Collectors.toList());
Collections.sort(list, new Comparator() {
@Override
public int compare(String o1, String o2) {
return (o2+o1).compareTo(o1+o2);
}
});
String ans = list.stream().collect(Collectors.joining(""));
return ans.equals(“00000”)?“0”:ans;
}
}