Skip to content

Commit 2135565

Browse files
committed
14 medium
1 parent a590c65 commit 2135565

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'''
2+
1. 아이디어 :
3+
ghost 거리가 target 거리보다 크면 탈출 가능 - 그냥 먼저 도달하면 됨
4+
2. 시간복잡도 :
5+
O(n)
6+
3. 자료구조/알고리즘 :
7+
'''
8+
class Solution:
9+
def escapeGhosts(self, ghosts: List[List[int]], target: List[int]) -> bool:
10+
me = abs(target[0]) + abs(target[1])
11+
g_lst = []
12+
for ghost in ghosts:
13+
g_lst.append(abs(ghost[0] - target[0]) + abs(ghost[1] - target[1]))
14+
15+
# print(g_lst)
16+
17+
return True if me < min(g_lst) else False

0 commit comments

Comments
 (0)