The method getLongestCommonPrefix
receives a list of Strings. Each element represents a word. The method should find and return the longest common prefix from all the words. If there is no prefix in common among all words, return ""
, an empty String.
Example 1:
Input: words: ['florida'', 'flower', 'flight'] Output: fl Explanation: Each word begins with fl
Example 2:
Input: words: ['bob', 'mark', 'steve'] Output: "" Explanation: There is no common prefix