0953 py

mac2022-06-30  23

class Solution: def isAlienSorted(self, words, order): alien_dic = {} # create alien dictionary by using enumerate for i, c in enumerate(order): alien_dic[c] = i dic_order = sorted(words, key=lambda x: [alien_dic[c] for c in x]) return dic_order == words
最新回复(0)