14. Longest Common Prefix
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
if(strs.empty())
return "";
string res=strs[0];
for(int i=1;i<strs.size();i++){
string temp;
for(int j=0;j<res.size() && j<strs[i].size();j++){
if(res[j]==strs[i][j]){
temp+=res[j];
}
else
break;
}
res=temp;
}
return res;
}
};