← Back to challenges

Sorted List of Words

PythonHardarraysconditionssortingstringsvalidation

Instructions

The function is given a list of words and a new alphabet (English letters in different order). Determine if the list of words is sorted lexicographically. The words consist of lower case letters.

Examples

is_sorted(["hello", "innokodakademijalot"], "hlabcdefgijkmnopqrstuvwxyz") ➞ True

is_sorted(["word", "world", "row"], "worldabcefghijkmnpqstuvxyz") ➞ False

is_sorted(["apple", "app"], "abcdefghijklmnopqrstuvwxyz") ➞ False

is_sorted(["deceased", "folks", "can", "vote"], "abdefghijklmnopqrstcuvwxyz") ➞ True

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.