当前位置:网站首页>LeetCode 1637. The widest vertical area between two points without any point
LeetCode 1637. The widest vertical area between two points without any point
2022-07-06 16:43:00 【Daylight629】
1637. The widest vertical area between two points without any points
Here you are. n Points on a two-dimensional plane points , among points[i] = [xi, yi] , Please return the point between two points without any point inside The widest vertical area Width .
Vertical area Is defined as a fixed width , and y An area on an axis that extends infinitely ( That is, the height is infinite ). The widest vertical area The vertical area with the largest width .
Please note that , Vertical area On the edge The point of be not in In the area .
Example 1:

Input :points = [[8,7],[9,9],[7,4],[9,7]]
Output :1
explain : The red area and the blue area are both optimal areas .
Example 2:
Input :points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]
Output :3
Tips :
n == points.length2 <= n <= 105points[i].length == 20 <= xi, yi <= 109
Two 、 Method 1
Maximum sorting value , Just look at the abscissa comparison
class Solution {
public int maxWidthOfVerticalArea(int[][] points) {
Arrays.sort(points, (a, b) -> a[0] - b[0]);
int res = 0;
for (int i = 0; i < points.length - 1; i++) {
res = Math.max(res, points[i + 1][0] - points[i][0]);
}
return res;
}
}
Complexity analysis
Time complexity :O(nlogn).
Spatial complexity :O(1).
边栏推荐
- Native JS realizes the functions of all selection and inverse selection -- Feng Hao's blog
- Remove the border when input is focused
- Codeforces Round #771 (Div. 2)
- Raspberry pie 4B installation opencv3.4.0
- CMake Error: Could not create named generator Visual Studio 16 2019解决方法
- Double specific tyrosine phosphorylation regulated kinase 1A Industry Research Report - market status analysis and development prospect prediction
- 第2章 HFDS的Shell操作
- 第6章 DataNode
- LeetCode 1561. The maximum number of coins you can get
- Discussion on QWidget code setting style sheet
猜你喜欢

Hbuilder X格式化快捷键设置

本地可视化工具连接阿里云centOS服务器的redis

图像处理一百题(1-10)

(lightoj - 1323) billiard balls (thinking)

300th weekly match - leetcode
![Story of [Kun Jintong]: talk about Chinese character coding and common character sets](/img/d5/9a9e3a0ba57328749d80ec71cb9467.png)
Story of [Kun Jintong]: talk about Chinese character coding and common character sets

Li Kou - 298th weekly match

SF smart logistics Campus Technology Challenge (no T4)

视频压缩编码和音频压缩编码基本原理

Hbuilder x format shortcut key settings
随机推荐
js时间函数大全 详细的讲解 -----阿浩博客
Base dice (dynamic programming + matrix fast power)
图像处理一百题(1-10)
Codeforces Round #801 (Div. 2)A~C
Installation and configuration of MariaDB
Soft music -js find the number of times that character appears in the string - Feng Hao's blog
力扣leetcode第 280 场周赛
OneForAll安装使用
两个礼拜速成软考中级软件设计师经验
MP4格式详解
Browser print margin, default / borderless, full 1 page A4
Codeforces Round #771 (Div. 2)
解决Intel12代酷睿CPU【小核载满,大核围观】的问题(WIN11)
Codeforces Global Round 19
Spark独立集群动态上线下线Worker节点
LeetCode 1984. Minimum difference in student scores
Problem - 922D、Robot Vacuum Cleaner - Codeforces
ffmpeg命令行使用
Li Kou leetcode 280 weekly match
第5章 NameNode和SecondaryNameNode