Sorted Array of Words

Published by Mubashir Hassan in

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

Examples

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

isSorted(["word", "world", "row"], "worldabcefghijkmnpqstuvxyz") ➞ false

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

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

Notes

N/A

Watch a quick demo on how Edabit works.