Trains the technique from
LeetCode 953Verifying an Alien DictionaryThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A typesetting house keeps its catalogue sorted by a house glyph sequence rather than by the usual alphabet. The string order lists all 26 lowercase letters exactly once, from the earliest glyph to the latest.
Under that sequence, one entry comes before another when, at the first position where the two entries carry different letters, this entry's letter appears earlier in order. If one entry is a prefix of the other, the shorter one comes first. Two identical entries may sit next to each other in either arrangement.
Given the catalogue words in the order it is printed, return true if no entry comes before the entry ahead of it, and false otherwise.
Example 1
In this glyph sequence t comes before b, so "hut" precedes "hub", and h comes before b, so "hub" precedes "bore".
Example 2
The glyph sequence is the ordinary alphabet here. "app" is a prefix of "apple", so the shorter entry has to be printed first, and it is not.
Example 3
"drum" before "drums" is fine by the prefix rule, but "drums" and "drop" first differ at position 2, where u comes after o.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def is_alien_sorted(words: list[str], order: str) -> bool:public boolean isAlienSorted(String[] words, String order)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.