Intermediate Level
Implement the method longestCommonPrefix that returns the shared starting text of all strings.
Return the longest prefix that appears at the beginning of every string in the input list.
The task is designed to test careful handling of edge cases, not only the most common input.
- Use only the first
sizestrings. - The input contains at least one string.
- Comparison is case-sensitive.
Start with the first string as the prefix and shorten it until every string starts with it.