Sorted Array of Words

Published by Deep Xavier in

Write a function that, for a given array of words and a new alphabet (English letters in different order), determines if the array of words is sorted lexicographically based on the new reordered set of alphabet. The given array of words will only contains lower case letters.

Examples

isSorted(["tesh", "love", "of", "my", "life", "and", "my", "world", "entirely"], "tlomawbdefghijknpqrscuvxyz") ➞ false

isSorted(["hello", "edabitlot"], "hlabcdefgijkmnopqrstuvwxyz") ➞ true

isSorted(["apple", "app"], "abcdefghijklmnopqrstuvwxyz") ➞ false

isSorted(["deceased", "folks", "can", "vote"], "abdefghijklmnopqrstcuvwxyz") ➞ true

Notes

N/A

Watch a quick demo on how Edabit works.