forked from neetcode-gh/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 1637-widest-vertical-area-between-two-points-containing-no-poi…
…nts.java
- Loading branch information
1 parent
b8fb88f
commit e147dcd
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
java/1637-widest-vertical-area-between-two-points-containing-no-points.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*-------------------------------- | ||
Time Complexity: O(nlog(n)) | ||
Space Complexity: O(1) | ||
---------------------------------*/ | ||
class Solution { | ||
public int maxWidthOfVerticalArea(int[][] points) { | ||
Arrays.sort(points, (p1, p2) -> p1[0] - p2[0]); | ||
|
||
int res = 0; | ||
for(int i = 1; i < points.length; i++){ | ||
res = Math.max(res, points[i][0] - points[i-1][0]); | ||
} | ||
return res; | ||
} | ||
} |