problem:
Write a function to find the longest common prefix string amongst an array of strings.
thinking:
(1)公共前綴很好理解,按位匹配即可
(2)很容易忘記處理0、1個字符串的情況。
code:
string prefix(string &str1, string &str2) { string tmp; int i=0; while((i&strs) { if(strs.size()==0) return ""; if(strs.size()==1) return strs.at(0); string result=prefix(strs.at(0),strs.at(1)); for(int i=1;i