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 "";
else if(strs.size() == 1)
return strs[0];
int current = 0;
while(1){
for(int i = 1; i < strs.size(); i++)
{
if(current >= strs[i].size() || current >= strs[0].size() || strs[i][current] != strs[0][current])
return strs[0].substr(0,current);
}
current++;
}
}
};