//日积月累,水滴石穿
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
if (strs.empty()) return ""; //必须要加空的特判
string res = "";
for(int i=;i < strs[].size();i++){
for(int j=;j < strs.size();j++){
if(i >= strs[j].size() || strs[j][i] != strs[][i])
return res;
}
res.push_back(strs[][i]);
}
return res;
}
};
int main()
{
string s[] = {"abca","abc"}; //内容为string的vector
vector<string> n;
n.insert(n.begin(),s,s+); Solution a;
cout << a.longestCommonPrefix(n) << endl; return ;
}

_

05-18 15:53