← Back to challenges

Sorted Array of Words

JavaScriptHardarraysconditionssortingstringsvalidation

Instructions

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(["hello", "innokodakademijalot"], "hlabcdefgijkmnopqrstuvwxyz") ➞ true

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

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

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

Notes

N/A

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