char * longestCommonPrefix(char ** strs, int strsSize){
char *a = malloc(sizeof(char) * 10000);
int j = 1, z = 0;
if (strsSize == 0)
return "";
if (strsSize == 1)
return strs[0];
for (int i = 0; i < strlen(strs[0][i]); ++i) {
while (strs[j][i] && strs[j - 1][i] == strs[j][i]) {
j++;
}
if (j == strsSize) {
j = 1;
a[z++] = strs[0][i];
}
else
break;
}
a[z] = '';
return a;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…