Write a function to find the longest common prefix string amongst an array of strings.
string subCommon(string& s1, string& s2){
int idx = 0, len = min(s1.size(), s2.size());
while ((s1[idx] == s2[idx]) && (idx < len)){
idx++;
}
return s1.substr(0, idx);
}
string longestCommonPrefix(vector<string>& strs) {
if (strs.size() == 0)return "";
if (strs.size() == 1)return strs[0];
string str = strs[0];
for (int i = 1; i < strs.size(); i++){
if (strs[i].empty()) return "";
else str = subCommon(str, strs[i]);
if (str == "")return "";
}
return str;
}