File tree 1 file changed +13
-12
lines changed
src/main/java/com/fishercoder/solutions 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change 31
31
*/
32
32
public class _624 {
33
33
34
- public int maxDistance (int [][] arrays ) {
35
- List <Integer > max = new ArrayList <>();
36
- for (int [] array : arrays ) {
37
- max .add (array [array .length - 1 ]);
34
+ public static class Solution1 {
35
+ public int maxDistance (int [][] arrays ) {
36
+ List <Integer > max = new ArrayList <>();
37
+ for (int [] array : arrays ) {
38
+ max .add (array [array .length - 1 ]);
39
+ }
40
+ Collections .sort (max );
41
+ int ans = Integer .MIN_VALUE ;
42
+ for (int [] array : arrays ) {
43
+ int big = array [array .length - 1 ] == max .get (max .size () - 1 ) ? max .get (max .size () - 2 ) : max .get (max .size () - 1 );
44
+ ans = Math .max (ans , big - array [0 ]);
45
+ }
46
+ return ans ;
38
47
}
39
- Collections .sort (max );
40
- int ans = Integer .MIN_VALUE ;
41
- for (int [] array : arrays ) {
42
- int big = array [array .length - 1 ] == max .get (max .size () - 1 ) ? max .get (max .size () - 2 ) : max .get (max .size () - 1 );
43
- ans = Math .max (ans , big - array [0 ]);
44
- }
45
- return ans ;
46
48
}
47
-
48
49
}
You can’t perform that action at this time.
0 commit comments