Skip to content

Practice Verifying an Alien Dictionary

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#953
LeetCode Problem

Verifying an Alien Dictionary

Problem Statement

In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographically in this alien language.

Source: Verifying an Alien Dictionary on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
words = ["hello","leetcode"], order = "hlabcdefgijkmnopqrstuvwxyz"
Output
true

# Example 2

Input
words = ["word","world","row"], order = "worldabcefghijkmnpqstuvxyz"
Output
false

# Example 3

Input
words = ["apple","app"], order = "abcdefghijklmnopqrstuvwxyz"
Output
false

Constraints

1 <= words.length <= 100
1 <= words[i].length <= 20
order.length == 26
All characters in words[i] and order are English lowercase letters.

Related LeetCode Problems

Practice more problems similar to Verifying an Alien Dictionary.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.