Verifying an Alien Dictionary
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
An alien language uses the 26 lowercase English letters, but in a different alphabetical order given by the string order (a permutation of a–z, first letter smallest).
Given a list words, return true if the words are sorted in non-decreasing lexicographic order under the alien alphabet, and false otherwise.
Lexicographic comparison works as usual: compare at the first position where two words differ; if one word is a prefix of the other, the shorter word comes first.
Examples
Constraints
- 1 <= words.length <= 100
- 1 <= words[i].length <= 20
- order.length == 26
- `order` is a permutation of the lowercase English letters
- `words[i]` consists of lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.