Write a function to find the longest common prefix string amongst an array of strings.
没啥难度,不多说了
public String longestCommonPrefix(String[] strs) { if(strs.length < 1) return ""; String pre = strs[0]; int i =0; while(i<strs.length){ while(strs[i].indexOf(pre) != 0){ pre = pre.substring(0,pre.length() -1); } i++; } return pre; }