package leetcode;

import java.util.Arrays;
import java.util.List;

/**
 * https://leetcode.com/problems/maximum-distance-in-arrays/
 */
public class Problem624 {
    public int maxDistance(List<List<Integer>> arrays) {
        // TODO:
        return 0;
    }

    public static void main(String[] args) {
        Problem624 prob = new Problem624();
        System.out.println(Arrays.asList(
            Arrays.asList(1, 2, 3),
            Arrays.asList(4, 5),
            Arrays.asList(1, 2, 3)
        )); // 4
        System.out.println(Arrays.asList(
            Arrays.asList(1, 2, 3),
            Arrays.asList(4, 5),
            Arrays.asList(1, 2, 10)
        )); // 9
        System.out.println(Arrays.asList(
            Arrays.asList(2, 3, 4),
            Arrays.asList(4, 5),
            Arrays.asList(1, 2, 10)
        )); // 8
    }
}

@@ -12,16 +12,44 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -65,16 +65,16 @@
 Arrays;%0A
-
 import j
@@ -253,33 +253,792 @@
     
-// TODO:%0A        return 0
+List%3CInteger%3E min = new ArrayList%3C%3E();%0A        List%3CInteger%3E max = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C arrays.size(); i++) %7B%0A            List%3CInteger%3E array = arrays.get(i);%0A            if (array.size() %3E= 2) %7B%0A                min.add(array.get(0));%0A                max.add(array.get(array.size() - 1));%0A            %7D else if (array.size() == 1) %7B%0A                min.add(array.get(0));%0A                max.add(array.get(0));%0A            %7D%0A        %7D%0A        int result = 0;%0A        for (int i = 0; i %3C min.size(); i++) %7B%0A            for (int j = 0; j %3C min.size(); j++) %7B%0A                if (i == j) %7B%0A                    continue;%0A                %7D%0A                result = Math.max(result, Math.abs(max.get(i) - min.get(j)));%0A            %7D%0A        %7D%0A        return result
 ;%0A  
@@ -1150,32 +1150,49 @@
 tem.out.println(
+prob.maxDistance(
 Arrays.asList(%0A 
@@ -1300,24 +1300,25 @@
 )%0A        ))
+)
 ; // 4%0A     
@@ -1331,32 +1331,49 @@
 tem.out.println(
+prob.maxDistance(
 Arrays.asList(%0A 
@@ -1482,24 +1482,25 @@
 )%0A        ))
+)
 ; // 9%0A     
@@ -1521,16 +1521,33 @@
 println(
+prob.maxDistance(
 Arrays.a
@@ -1658,24 +1658,24 @@
  2, 10)%0A
-
         
 )); // 8
@@ -1666,16 +1666,17 @@
         
+)
 )); // 8

Update problem 624