...

/

Verifying an Alien Dictionary

Verifying an Alien Dictionary

Try to solve the Verifying an Alien Dictionary problem.

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:

  • 11 \leq words.length 103\leq 10^3
  • 11 \leq words[i].length 20\leq 20
  • order.length ==26== 26
  • All the characters in words[i] and order are lowercase English letters.

Examples

1 / 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

1

What is the output if the following list of words and order are given as input?

words = [“hello”, “to”, “my”, “world”]

order = “hlabcdefgijkmnopqrstuvwxyz”

A)

TRUE

B)

FALSE

Question 1 of 40 attempted

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.

Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence.

1
2
3
4
5
6

Try it yourself

Implement your solution in the following coding playground:

Press + to interact
Python
usercode > main.py
def verify_alien_dictionary(words, order):
# Replace this placeholder return statement with your code
return False
Verifying an Alien Dictionary

Access this course and 1200+ top-rated courses and projects.