953. Verifying an Alien Dictionary
class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
N = len(words)
dic = {c: i for i, c in enumerate(order)}
alien_words = []
for word in words:
new_word = []
for c in word:
new_word.append(dic[c])
alien_words.append(new_word)
for i in range(1, N):
word1, word2 = alien_words[i-1], alien_words[i]
if word1 > word2:
return False
return True