当前位置:网站首页>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).
边栏推荐
- Codeforces Round #798 (Div. 2)A~D
- Spark独立集群Worker和Executor的概念
- QT simulates mouse events and realizes clicking, double clicking, moving and dragging
- (lightoj - 1370) Bi shoe and phi shoe (Euler function tabulation)
- (POJ - 1458) common subsequence (longest common subsequence)
- Market trend report, technological innovation and market forecast of China's double sided flexible printed circuit board (FPC)
- Market trend report, technical innovation and market forecast of China's desktop capacitance meter
- Tert butyl hydroquinone (TBHQ) Industry Research Report - market status analysis and development prospect forecast
- MariaDB的安装与配置
- Chapter 5 yarn resource scheduler
猜你喜欢

解决Intel12代酷睿CPU单线程只给小核运行的问题

Chapter 6 rebalance details

Solve the single thread scheduling problem of intel12 generation core CPU (II)

Mp4 format details

LeetCode 1557. The minimum number of points that can reach all points

(lightoj - 1369) answering queries (thinking)

Business system compatible database oracle/postgresql (opengauss) /mysql Trivia

第7章 __consumer_offsets topic

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

Chapter 7__ consumer_ offsets topic
随机推荐
Acwing: the 56th weekly match
Chapter 5 yarn resource scheduler
简单尝试DeepFaceLab(DeepFake)的新AMP模型
LeetCode 1552. Magnetic force between two balls
本地可视化工具连接阿里云centOS服务器的redis
QT simulates mouse events and realizes clicking, double clicking, moving and dragging
(lightoj - 1236) pairs forming LCM (prime unique decomposition theorem)
Codeforces Round #800 (Div. 2)AC
第三章 MapReduce框架原理
两个礼拜速成软考中级软件设计师经验
It is forbidden to trigger onchange in antd upload beforeupload
Story of [Kun Jintong]: talk about Chinese character coding and common character sets
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Mp4 format details
Native JS realizes the functions of all selection and inverse selection -- Feng Hao's blog
Market trend report, technical innovation and market forecast of tabletop dishwashers in China
Chapter III principles of MapReduce framework
Study notes of Tutu - process
Market trend report, technological innovation and market forecast of China's double sided flexible printed circuit board (FPC)
Codeforces Round #771 (Div. 2)