Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6661dfa

Browse files
Create Solution.py
1 parent ab13894 commit 6661dfa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def isAlienSorted(self, words: List[str], order: str) -> bool:
3+
myDict = {}
4+
k = ord('a')
5+
for i in order:
6+
myDict[i] = chr(k)
7+
k += 1
8+
prev = ""
9+
for word in words:
10+
cur = ""
11+
for c in word:
12+
cur += myDict[c]
13+
if cur < prev:
14+
return False
15+
prev = cur
16+
return True

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /