当前位置:网站首页>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).
边栏推荐
- LeetCode 1560. The sector with the most passes on the circular track
- Market trend report, technological innovation and market forecast of desktop electric tools in China
- Research Report on market supply and demand and strategy of China's four flat leadless (QFN) packaging industry
- QT implementation window gradually disappears qpropertyanimation+ progress bar
- Specify the format time, and fill in zero before the month and days
- 第5章 消费者组详解
- Anaconda下安装Jupyter notebook
- Chapter 2 shell operation of hfds
- Cmake Express
- Remove the border when input is focused
猜你喜欢

Two weeks' experience of intermediate software designer in the crash soft exam

It is forbidden to trigger onchange in antd upload beforeupload

Soft music -js find the number of times that character appears in the string - Feng Hao's blog

Advancedinstaller installation package custom action open file

js封装数组反转的方法--冯浩的博客

Spark independent cluster dynamic online and offline worker node

Codeforces Round #802(Div. 2)A~D

Spark独立集群动态上线下线Worker节点

Kubernetes集群部署

Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog
随机推荐
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
第6章 Rebalance详解
软通乐学-js求字符串中字符串当中那个字符出现的次数多 -冯浩的博客
Discussion on QWidget code setting style sheet
QT implementation window gradually disappears qpropertyanimation+ progress bar
解决Intel12代酷睿CPU单线程调度问题(二)
使用jq实现全选 反选 和全不选-冯浩的博客
Market trend report, technological innovation and market forecast of desktop electric tools in China
LeetCode 1552. Magnetic force between two balls
LeetCode 1550. There are three consecutive arrays of odd numbers
Basic principles of video compression coding and audio compression coding
Story of [Kun Jintong]: talk about Chinese character coding and common character sets
Chapter 2 shell operation of hfds
QT simulates mouse events and realizes clicking, double clicking, moving and dragging
业务系统兼容数据库Oracle/PostgreSQL(openGauss)/MySQL的琐事
第三章 MapReduce框架原理
How to insert mathematical formulas in CSDN blog
Hbuilder x format shortcut key settings
(lightoj - 1323) billiard balls (thinking)
Spark独立集群动态上线下线Worker节点