今際の国の呵呵君
Wednesday, May 30, 2018
[LintCode]Digital Coverage
给定一堆interval,每个interval的起始为start,终点为end,start和end均为整数,其cover[start, end]的区间。求哪个数被覆盖的次数最多,如果最多的有多个输出最小的那个。这道题和
Meeting Rooms II
是一样的,我么 用一根线从左向右扫,与所有interval相交最多的点就是答案。时间复杂度空间复杂度均为O(n),代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment