- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1637.java
25 lines (23 loc) · 732 Bytes
/
_1637.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
packagecom.fishercoder.solutions.secondthousand;
importjava.util.ArrayList;
importjava.util.List;
importjava.util.TreeSet;
publicclass_1637 {
publicstaticclassSolution1 {
publicintmaxWidthOfVerticalArea(int[][] points) {
TreeSet<Integer> treeSet = newTreeSet<>();
for (int[] point : points) {
treeSet.add(point[0]);
}
intans = 0;
List<Integer> list = newArrayList<>();
for (intx : treeSet) {
list.add(x);
}
for (inti = 0; i < list.size() - 1; i++) {
ans = Math.max(ans, list.get(i + 1) - list.get(i));
}
returnans;
}
}
}