标签:
public class Solution { public String longestCommonPrefix(String[] strs) { //http://www.cnblogs.com/springfor/p/3872316.html if(strs==null || strs.length==0|| strs[0].length()==0) return ""; for(int i=0;i<strs[0].length();i++){ char x = strs[0].charAt(i); for(int j=1;j<strs.length;j++){ if(strs[j].length()==i||strs[j].charAt(i)!=x) return strs[0].substring(0,i); } } return strs[0]; } }
标签:
原文地址:http://www.cnblogs.com/jiajiaxingxing/p/4537654.html