15% off all plans & roadmaps Use code
See plansProblem editorial
Implement Solution.isAlienSorted(words, order) to determine whether the list words is sorted according to an alien alphabet. The string order gives the complete character ranking: a character appearing earlier in order is considered smaller than one appearing later.
Verifying an Alien Dictionary is a Array/Matrix Manipulation Patterns problem, in the Hashing - Frequency Map / Counting subpattern. The pattern covers in-place operations, hashing, prefix sums, spiral traversal, and cyclic sort
The reference solution runs in O(sum of the lengths of the words) in the worst case. time and O(1), using a fixed-size 26-element ranking array. space.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Verifying an Alien Dictionary is a Array/Matrix Manipulation Patterns problem, in the Hashing - Frequency Map / Counting subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.