File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ from typing import (
2
+ List ,
3
+ )
4
+ from lintcode import (
5
+ Interval ,
6
+ )
7
+
8
+ """
9
+ Definition of Interval:
10
+ class Interval(object):
11
+ def __init__(self, start, end):
12
+ self.start = start
13
+ self.end = end
14
+ """
15
+
16
+ class Solution :
17
+ """
18
+ @param intervals: an array of meeting time intervals
19
+ @return: if a person could attend all meetings
20
+ """
21
+ def can_attend_meetings (self , intervals : List [Interval ]) -> bool :
22
+
23
+ # ์๊ฐ๋ณต์ก๋(O(n^2)), ๊ณต๊ฐ๋ณต์ก๋ O(1)
24
+ # ์์์ ์ ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ(์ ํ์ ๋ ฌ)
25
+ for i in range (len (intervals )):
26
+ idx = i
27
+ for j in range (i + 1 ,len (intervals )):
28
+ if intervals [j ].start < intervals [idx ].start :
29
+ idx = j
30
+ if idx != i :
31
+ intervals [i ], intervals [idx ] = intervals [idx ], intervals [i ]
32
+
33
+ # ๊ฒน์น๋ ํ์ ์๋์ง ํ์ธ
34
+ for i in range (1 , len (intervals )):
35
+ if intervals [i ].start < intervals [i - 1 ].end :
36
+ return False
37
+
38
+ return True
You canโt perform that action at this time.
0 commit comments