列表数据类型是否具有开始或结束属性?

时间:2019-04-20 03:33:25

标签: list attributes python-3.6

每次运行它时,都会弹出错误消息。

如果没有,为什么我看到人们到处都在循环使用list.start或list.end ????

示例代码:

def minMeetingRooms(self, intervals):
    starts = []
    ends = []
    for i in intervals:
        starts.append(i.start)
        ends.append(i.end)

    starts.sort()
    ends.sort()
    s = e = 0
    numRooms = available = 0
    while s < len(starts):
        if starts[s] < ends[e]:
            if available == 0:
                numRooms += 1
            else:
                available -= 1

            s += 1
        else:
            available += 1
            e += 1

    return numRooms

'''

0 个答案:

没有答案