題意為找到所有字符串的最長的共同前綴。
思路:
1.先遍歷一遍,得出最短字符串的長度
2.對每一個字符串均與第一個字符串比較,出現不同,則得出最長公共前綴到此結束
class Solution {
public:
string longestCommonPrefix(vector &strs) {
int len=strs.size();
int min=INT_MAX;
string commomPrefix;
if(len==0)
return commomPrefix;
for(int k=0;k