题目
结果
运行效果:
代码如下:
class Solution {
public String longestCommonPrefix(String[] strs) {
if(strs==null || strs.length<=0){
return "";
}
if(strs[0]==null||strs.length<=0){
return "";
}
int minLength = strs[0].length();
int minIndex = 0;
for(int i = 1;i < strs.length;i++){
String target = strs[i];
if (target == null || target.length() <= 0) {
return "";
}