Verifying an Alien Dictionary
class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
cache = {c: ix for ix, c in enumerate(order)}
N = len(words)
for ix in range(N - 1):
w1 = words[ix]
w2 = words[1 + ix]
for cx in range(len(w1)):
if cx > len(w2) - 1:
return False
if w1[cx] != w2[cx]:
if cache[w1[cx]] > cache[w2[cx]]:
return False
break
return True