#K67717. Alien Dictionary Order Verification
Alien Dictionary Order Verification
Alien Dictionary Order Verification
In this problem, you are given a list of words and a custom ordering of the alphabet defined by an alien language. Your task is to determine whether the list of words is sorted in lexicographical order based on the provided alien order.
Formally, you are given an integer (n) denoting the number of words, followed by (n) words, and a string (order) representing the order of characters in the alien alphabet. For any two words (w_1) and (w_2), (w_1) is considered to come before (w_2) if at the first index where they differ the character in (w_1) appears earlier in (order) than the corresponding character in (w_2). Additionally, if one word is a prefix of the other, the shorter word is considered to come first.
inputFormat
The input is read from standard input (stdin) in the following format:
(1) An integer (n) representing the number of words.
(2) (n) lines, each containing a word.
(3) A single line containing the string (order), which represents the alien dictionary order.
outputFormat
Output a single line to standard output (stdout) with either "true" if the words are sorted according to the alien language order or "false" otherwise.## sample
3
hello
leetcoder
leetcode
hlabcdefgijkmnopqrstuvwxyz
false