953. Verifying an Alien Dictionary
https://leetcode.com/problems/verifying-an-alien-dictionary
Python
Hashmap
class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
mapper = {letter: i for i, letter in enumerate(order)}
decoded = [
[mapper[letter] for letter in word]
for word in words
]
for i in range(1, len(decoded)):
if decoded[i] < decoded[i-1]:
return False
return True