Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit263e016

Browse files
add a solution for 624
1 parent52642b0 commit263e016

File tree

1 file changed

+16
-0
lines changed
  • src/main/java/com/fishercoder/solutions/firstthousand

1 file changed

+16
-0
lines changed

‎src/main/java/com/fishercoder/solutions/firstthousand/_624.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,20 @@ public int maxDistance(List<List<Integer>> arrays) {
2121
returnans;
2222
}
2323
}
24+
25+
publicstaticclassSolution2 {
26+
publicintmaxDistance(List<List<Integer>>arrays) {
27+
intmin =arrays.get(0).get(0);
28+
intmax =arrays.get(0).get(arrays.get(0).size() -1);
29+
intans =0;
30+
for (inti =1;i <arrays.size();i++) {
31+
List<Integer>curr =arrays.get(i);
32+
ans =Math.max(ans,Math.abs(max -curr.get(0)));
33+
ans =Math.max(ans,Math.abs(curr.get(curr.size() -1) -min));
34+
max =Math.max(max,curr.get(curr.size() -1));
35+
min =Math.min(min,curr.get(0));
36+
}
37+
returnans;
38+
}
39+
}
2440
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp