Recca Chao 的 gitHub page

推廣網站開發,包含 Laravel 和 Kotlin 後端撰寫、自動化測試、讀書心得等。Taiwan Kotlin User Group 管理員。

View on GitHub

Hi, here’s your problem today. This problem was recently asked by Facebook:

Given a list of meetings that will happen during a day, find the minimum number of meeting rooms that can fit all meetings.

Each meeting will be represented by a tuple of (start_time, end_time), where both start_time and end_time will be represented by an integer to indicate the time. start_time will be inclusive, and end_time will be exclusive, meaning a meeting of (0, 10) and (10, 20) will only require 1 meeting room.

Here’s some examples and some starting code:

def meeting_rooms(meetings):

Fill this in.

print 1

print(meeting_rooms([(0, 10), (10, 20)]))

1

print(meeting_rooms([(20, 30), (10, 21), (0, 50)]))

3 (all meetings overlap at time 20)