/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param strs string字符串一维数组 * @param strsLen int strs数组长度 * @return string字符串 */ char str[5001]={'0'}; int judge(char x1,char x2) { if(x1==x2) return 1; else return 0; } char* longestCommonPrefix(char** strs, int strsLen ) { // write code here int i=0,j=0; if(strsLen==0) return ""; if(strsLen==1) { return *strs; } while(1) { for(int i=0;i<strsLen-1;i++) { while(!judge(strs[i][j],strs[i+1][j])) { goto next; } } j++; } next: if(j==0) return ""; else for(int i=0;i<j;i++) { str[i]=strs[0][i]; } return str; }