#C521. Alien Dictionary Sorting
Alien Dictionary Sorting
Alien Dictionary Sorting
Given a list of words and a string representing the order of characters in an alien language, determine whether the words are sorted lexicographically according to this alien language.
Assume that:
- There are n words.
- The alien alphabet is a permutation of the standard lowercase English letters.
The task is to verify if, for every two adjacent words \( w_i \) and \( w_{i+1} \), the order relation defined by the alien language holds true. In other words, if all corresponding characters compare equal up to the shorter word, then the first word must not be longer than the second.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \( n \) indicating the number of words.
- The next \( n \) lines each contain a word.
- The last line contains a string representing the alien language order.
outputFormat
Output a single line to standard output (stdout) containing either "True" or "False" (without quotes). "True" indicates that the words are sorted according to the alien dictionary order, while "False" indicates otherwise.
## sample2
hello
leetcode
hlabcdefgijkmnopqrstuvwxyz
True