package programmertest;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Problem4 {
    public static int largest(List<Integer> numbers) {
        List<String> strings = numbers.stream().map(e -> e.toString())
            .collect(Collectors.toList());
        Collections.sort(strings, (a, b) -> {
            int minLength = Math.min(a.length(), b.length());
            for (int i = 0; i < minLength; i++) {
                int x = Integer.parseInt("" + a.charAt(i));
                int y = Integer.parseInt("" + b.charAt(i));
                if (x < y) {
                    return 1;
                } else if (x > y) {
                    return -1;
                }
            }
            return 0;
        });
        StringBuilder sb = new StringBuilder();
        for (String s : strings) {
            sb.append(s);
        }
        return Integer.parseInt(sb.toString());
    }
    
    public static void main(String[] args) {
        System.out.println(largest(Arrays.asList(50, 2, 1, 9)));
    }
}

@@ -388,406 +388,71 @@
     
-int minLength = Math.min(a.length(), b.length());%0A            for (int i = 0; i %3C minLength; i++) %7B%0A                int x = Integer.parseInt(%22%22
+return Integer.valueOf(b
  + a
+)
 .c
-harAt(i));%0A                int y = Integer.parseInt(%22%22 + b.charAt(i));%0A                if (x %3C y) %7B%0A                    return 1;%0A                %7D else if (x %3E y) %7B%0A                    return -1;%0A                %7D%0A            %7D%0A            return 0
+ompareTo(Integer.valueOf(a + b))
 ;%0A  
@@ -680,24 +680,24 @@
 g%5B%5D args) %7B%0A
-
         Syst
@@ -745,20 +745,149 @@
 2, 1, 9)));%0A
+        System.out.println(largest(Arrays.asList(5, 50, 56)));%0A        System.out.println(largest(Arrays.asList(420, 42, 423)));%0A
     %7D%0A%7D%0A

Fix a bug in problem 4