标签:size https amp etc for str efi problem href
https://leetcode.com/problems/longest-common-prefix/
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
if(strs.empty()) return "";
string ans=strs[0];
for(int i=0;i<strs[0].size();++i)
for(int j=1;j<strs.size();++j){
if(i>=strs[j].size() || strs[j][i]!=ans[i])
return string(ans,0,i);
}
return ans;
}
};
Leetcode 14. Longest Common Prefix
标签:size https amp etc for str efi problem href
原文地址:https://www.cnblogs.com/ximelon/p/10774054.html