当前位置:网站首页>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.length
2 <= n <= 105
points[i].length == 2
0 <= 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).
边栏推荐
- Market trend report, technical innovation and market forecast of China's desktop capacitance meter
- 解决Intel12代酷睿CPU【小核载满,大核围观】的问题(WIN11)
- LeetCode 1560. The sector with the most passes on the circular track
- SQL快速入门
- Chapter III principles of MapReduce framework
- Double specific tyrosine phosphorylation regulated kinase 1A Industry Research Report - market status analysis and development prospect prediction
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- FLV格式详解
- Educational Codeforces Round 122 (Rated for Div. 2)
- One hundred questions of image processing (1-10)
猜你喜欢
QT simulates mouse events and realizes clicking, double clicking, moving and dragging
第五章 Yarn资源调度器
Base dice (dynamic programming + matrix fast power)
提交Spark应用的若干问题记录(sparklauncher with cluster deploy mode)
It is forbidden to trigger onchange in antd upload beforeupload
视频压缩编码和音频压缩编码基本原理
业务系统兼容数据库Oracle/PostgreSQL(openGauss)/MySQL的琐事
Story of [Kun Jintong]: talk about Chinese character coding and common character sets
Codeforces Round #799 (Div. 4)A~H
Chapter III principles of MapReduce framework
随机推荐
Raspberry pie 4B installation opencv3.4.0
Acwing: the 56th weekly match
< li> dot style list style type
使用jq实现全选 反选 和全不选-冯浩的博客
Basic principles of video compression coding and audio compression coding
视频压缩编码和音频压缩编码基本原理
One hundred questions of image processing (1-10)
LeetCode 1561. The maximum number of coins you can get
软通乐学-js求字符串中字符串当中那个字符出现的次数多 -冯浩的博客
MP4格式详解
Investigation report of bench type Brinell hardness tester industry - market status analysis and development prospect prediction
Chapter 1 overview of MapReduce
JS time function Daquan detailed explanation ----- AHAO blog
CMake速成
第7章 __consumer_offsets topic
LeetCode 1447. Simplest fraction
Calculate the time difference
Story of [Kun Jintong]: talk about Chinese character coding and common character sets
QT implementation fillet window
Educational Codeforces Round 122 (Rated for Div. 2)