forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_1637.java
More file actions
25 lines (23 loc) · 717 Bytes
/
_1637.java
File metadata and controls
25 lines (23 loc) · 717 Bytes
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
package com.fishercoder.solutions;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
public class _1637 {
public static class Solution1 {
public int maxWidthOfVerticalArea(int[][] points) {
TreeSet<Integer> treeSet = new TreeSet<>();
for (int[] point : points) {
treeSet.add(point[0]);
}
int ans = 0;
List<Integer> list = new ArrayList<>();
for (int x : treeSet) {
list.add(x);
}
for (int i = 0; i < list.size() - 1; i++) {
ans = Math.max(ans, list.get(i + 1) - list.get(i));
}
return ans;
}
}
}