Verifying an Alien Dictionary
Try to solve the Verifying an Alien Dictionary problem.
We'll cover the following
Statement#
You’re given a list of words with lowercase English letters in a different order, written in an alien language. The order of the alphabet is some permutation of lowercase letters of the English language.
We have to return TRUE if the given list of words is sorted lexicographically in this alien language.
Constraints:
-
words.length -
words[i].length order.length- All the characters in
words[i]andorderare lowercase English letters.
Examples#
1 of 4
2 of 4
3 of 4
4 of 4
Understand the problem#
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Verifying an Alien Dictionary
What is the output if the following list of words and order are given as input?
words = [“wrt”, “wrf”, “er”, “ett”, “rftt”]
order = “hlabcdgiwjkmnopqerstfuvxyz”
TRUE
FALSE
Figure it out!#
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself#
Implement your solution in the following coding playground:
Topological Sort: Introduction
Solution: Verifying an Alien Dictionary