Leetcode Meeting room问题系列 - 1

这个问题系列就是list里面每个元素都有一个start和end时间.

google和amazon经常考的题目。

1.Merge Intervals(medium)

https://leetcode.com/problems/merge-intervals/

2. Meeting Rooms (easy)

https://leetcode.com/problems/meeting-rooms/

3. Meeting Rooms II(Medium)

https://leetcode.com/problems/meeting-rooms-ii/

4. Partition Labels(Medlium)

https://leetcode.com/problems/partition-labels/

5. Employee Free Time (hard)

https://leetcode.com/problems/employee-free-time/

 

这类问题主要是数值范围交叉问题,比如问题 2,问题3, 问题1

问题2就是给你一个会议时间集合list,每个元素有开始和结束时间。看看是否一个人可以参加所有的会议。

比如下面的例子

Input:[[0,30],[5,10],[15,20]]

Output:false

Example 2:

Input:[[7,10],[2,4]]

Output:true

问题3 同样也是给你一个会议时间集合list每个元素有开始和结束时间。看看是需要会议室的最小数目

Example 1:

Input:[[0, 30],[5, 10],[15, 20]]

Output:2

Example 2:

Input:[[7,10],[2,4]]

Output:1

 

问题1 给你一个数字范围集合list,合并重复的集合。

Example 1:

Input:[[1,3],[2,6],[8,10],[15,18]]

Output:[[1,6],[8,10],[15,18]]

Explanation:Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].

Example 2:

Input:[[1,4],[4,5]]

Output:[[1,5]]

Explanation:Intervals [1,4] and [4,5] are considered overlapping.

 

问题4 就是给你一个员工的工作时间集合,找出到家共同有空的时间段。Example 1:

Input:schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]

Output:[[3,4]]

Explanation:

There are a total of three employees, and all common

free time intervals would be [-inf, 1], [3, 4], [10, inf].

We discard any intervals that contain inf as they aren't finite.

Example 2:

Input:schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]

Output:[[5,6],[7,9]]

 

你可能感兴趣的:(LeetCode,python)