Skip to content

Commit cf6beca

Browse files
committed
Runtime: 74 ms (Top 17.14%) | Memory: 13.7 MB (Top 99.39%)
1 parent e759413 commit cf6beca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
# Runtime: 74 ms (Top 17.14%) | Memory: 13.7 MB (Top 99.39%)
12
class Solution:
23
def isAlienSorted(self, words: List[str], order: str) -> bool:
34
order_index = {key:index for index, key in enumerate(order)}
4-
5-
for i in range(len(words)-1):
5+
6+
for i in range(len(words)-1):
67
w1,w2 = words[i] , words[i + 1]
78
for j in range(len(w1)):
89
if j == len(w2):
910
return False
1011
if w1[j] != w2[j]:
11-
if order_index.get(w2[j]) < order_index.get(w1[j]):
12+
if order_index.get(w2[j]) < order_index.get(w1[j]):
1213
return False
1314
break
14-
return True
15+
return True

0 commit comments

Comments
 (0)