/*
6.找出一个字符串组的最长的公共前缀。Write a function to find the longest common prefix string amongst an array of strings.
*/
/*
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
if (strs.size() == 0) return "";
if (strs.size() == 1) return strs[0];
string pre = strs[0];
for (int i=1;i<strs.size();++i)
{
if (pre.size()==0 || strs[i].size()==0) {return "";}
int nmin = pre.size()>strs[i].size()?strs[i].size():pre.size();
int len = 0;
while(pre[len] == strs[i][len])
{
++len;
}
pre = strs[i].substr(0,len);
}
return pre;
}
};
*/
6.找出一个字符串组的最长的公共前缀。Write a function to find the longest common prefix string amongst an array of strings.
*/
/*
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
if (strs.size() == 0) return "";
if (strs.size() == 1) return strs[0];
string pre = strs[0];
for (int i=1;i<strs.size();++i)
{
if (pre.size()==0 || strs[i].size()==0) {return "";}
int nmin = pre.size()>strs[i].size()?strs[i].size():pre.size();
int len = 0;
while(pre[len] == strs[i][len])
{
++len;
}
pre = strs[i].substr(0,len);
}
return pre;
}
};
*/