Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "".
Example 1
Input: strs = ["flower","flow","flight"]
Output: fl
Explanation: All three words start with "fl", but at the third character "flower" and "flow" have 'o' while "flight" has 'i'. So the common prefix is "fl".
Example 2
Input: strs = ["dog","racecar","car"]
Output:
Explanation: The words start with 'd', 'r' and 'c', so they do not even share a first letter. The answer is the empty string.
Example 3
Input: strs = ["interspecies","interstellar","interstate"]
Output: inters
Explanation: All three words start with "inters". At the next character they differ ('p', 't' and 't' vs. "interspecies"), so the common prefix is "inters".
Compare the strings column by column: at each character position, every string must share the same character. Stop at the first column where they disagree or some string ends — everything before that is the common prefix.
Run checks all cases above. Submit evaluates all test cases.