
Sweep Line
flyatcmu
这个作者很懒,什么都没留下…
展开
-
Car Pooling
There is a car withcapacityempty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).You are given the integercapacityand an arraytripswheretrips[i] = [numPassengersi, fromi, toi]indicates that theithtrip hasnumPas...原创 2022-04-20 08:40:36 · 249 阅读 · 0 评论 -
Employee Free Time
We are given a listscheduleof employees, which represents the working time for each employee.Each employee has a list of non-overlappingIntervals, and these intervals are in sorted order.Return...原创 2020-05-02 05:49:24 · 367 阅读 · 0 评论 -
Brick Wall
There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from thetopto thebottomand cross theleastbricks.The brick wall is r...原创 2020-06-20 04:49:22 · 328 阅读 · 0 评论 -
My Calendar II
Implement aMyCalendarTwoclass to store your events. A new event can be added if adding the event will not cause atriplebooking.Your class will have one method,book(int start, int end). Formally...原创 2020-05-04 12:59:18 · 273 阅读 · 0 评论 -
My Calendar III
Implement aMyCalendarThreeclass to store your events. A new event canalwaysbe added.Your class will have one method,book(int start, int end). Formally, this represents a booking on the half ope...原创 2020-05-04 13:16:04 · 276 阅读 · 0 评论 -
Split a String in Balanced Strings
Balancedstrings are those who have equal quantity of 'L' and 'R' characters.Given a balanced stringssplit it in the maximum amount of balanced strings.Return the maximum amount of splitted bala...原创 2020-03-09 14:28:18 · 294 阅读 · 0 评论 -
Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si< ei), find the minimum number of conference rooms required.For example,Given[[0, 30],[5,...原创 2016-09-11 10:35:05 · 1084 阅读 · 0 评论 -
Meeting Rooms
Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.ExampleExample1Input: intervals = ...原创 2016-07-10 02:54:18 · 267 阅读 · 0 评论 -
The Skyline Problem
水平面上有N座大楼,每座大楼都是矩阵的形状,可以用一个三元组表示(start, end, height),分别代表其在x轴上的起点,终点和高度。大楼之间从远处看可能会重叠,求出N座大楼的外轮廓线。外轮廓线的表示方法为若干三元组,每个三元组包含三个数字 (start, end, height),代表这段轮廓的起始位置,终止位置和高度。Example样例1输入:[ ...原创 2020-01-14 16:06:28 · 801 阅读 · 0 评论 -
扫描线Sweep Line算法总结
Number of Airplanes in the Sky给出飞机的起飞和降落时间的列表,用序列interval表示. 请计算出天上同时最多有多少架飞机?Example样例 1:输入: [(1, 10), (2, 3), (5, 8), (4, 7)]输出: 3解释: 第一架飞机在1时刻起飞, 10时刻降落.第二架飞机在2时刻起飞, 3时刻降落.第三架飞机在5时刻...原创 2020-01-13 15:33:37 · 7235 阅读 · 1 评论 -
Time Intersection
Give two users' ordered online time series, and each section records the user's login time pointxand offline time pointy. Find out the time periods when both users are online at the same time, and ...原创 2019-12-05 13:18:34 · 643 阅读 · 0 评论 -
Number of Airplanes in the Sky
Given an listinterval, which are taking off and landing time of the flight. How many airplanes are there at most at the same time in the sky?ExampleExample 1:Input: [(1, 10), (2, 3), (5, 8), (...原创 2019-12-04 15:53:27 · 1003 阅读 · 0 评论