Desicription Write a function to find the longest common prefix string amongst an array of strings. Solution 12345678910111213141516 class {public: string longestCommonPrefix(vector<string>& strs) { if(strs.size() == 0) return ""; string res; for(int i = 0; strs[0][i]; i++){ for(int j = 0; j < strs.size(); j++){ if(strs[j][i] != strs[0][i] || strs[j].size() == i) return res; } res += strs[0][i]; } return res; }}; 赞微海报分享
近期评论