Write a function to find the longest common prefix string amongst an array of strings.
暴力破解,逐个比较字符
public string LongestCommonPrefix(string[] strs)
{
if (strs.Length == 0)
return "";
string s = strs[0];
for (int i = 0; i < s.Length; i++)
{
for (int j = 1; j < strs.Length; j++)
{
if (strs[j].Length <= i)
return s.Substring(0, i);
if(strs[j][i]!=s[i])
return s.Substring(0, i);
}
}
return s;
}