python leetCode - 会议室II

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python leetCode - 会议室II相关的知识,希望对你有一定的参考价值。

def minMeetingRoom(intervals):
    if intervals is None or len(intervals)==0:
        return 0
    tmp = []
    for inter in intervals:
        tmp.append((inter.start,True))
        tmp.append((inter.end,False))
    
    tmp = sorted(tmp,key=lambda v:(v[0],v[1]))

    n=0
    max_num=0
    for arr in tmp:
        if arr[1]:
            n+=1
        else:
            n-=1
        max_num = max(max_num,n)
    return max_num

以上是关于python leetCode - 会议室II的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 253. Meeting Rooms II(会议室)

LeetCode 第 253 题:会议室II

C语言刷leetcode——贪心

Facebook题库汇总

LeetCode 45. 跳跃游戏 II | Python

[LeetCode]题解(python):113 Path Sum II