Created
December 3, 2022 19:08
-
-
Save TangoPJ/eceda42ce2bf4d03a9327ecf879c6b62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const longestCommonPrefix = (strings) => { | |
if (strings.length === 1) { | |
return strings[0]; | |
} | |
const sortedStrings = strings.sort(); | |
const first = sortedStrings.at(0).split(''); | |
const last = sortedStrings.at(-1); | |
let result = ''; | |
// here will be a character-by-character check | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment