Die Aufgabe wird geladen…
In a normal dictionary, letters follow a through z, but an alien language may use a different alphabet order. Given a list of words words and a string order describing that alphabet, check whether the words are sorted lexicographically by the alien rules. Return True if they are in order, otherwise return False.
["hello", "leetcode"], "hlabcdefgijkmnopqrstuvwxyz"True["word", "world", "row"], "worldabcefghijkmnpqstuvxyz"False["apple", "app"], "abcdefghijklmnopqrstuvwxyz"Falsedef is_alien_sorted(words: list[str], order: str) -> bool:
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
Anmelden["hello","leetcode"], "hlabcdefgijkmnopqrstuvwxyz"True["word","world","row"], "worldabcefghijkmnpqstuvxyz"False["apple","app"], "abcdefghijklmnopqrstuvwxyz"False["a","b","c"], "abcdefghijklmnopqrstuvwxyz"True["kuvp","q"], "ngxlkthsjuoqcpavbfdermiywz"True["row","word","world"], "worldabcefghijkmnpqstuvxyz"False