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