未验证 提交 bb4630cf 编写于 作者: S SnailClimb 提交者: GitHub

Merge pull request #410 from keepal7/master

fix : 最长公共前缀题目数组检测函数修复
......@@ -135,17 +135,21 @@ public class Main {
}
private static boolean checkStrs(String[] strs) {
if (strs != null) {
// 遍历strs检查元素值
for (int i = 0; i < strs.length; i++) {
if (strs[i] == null || strs[i].length() == 0) {
return false;
}
}
}
return true;
}
private static boolean chechStrs(String[] strs) {
boolean flag = false;
if (strs != null) {
// 遍历strs检查元素值
for (int i = 0; i < strs.length; i++) {
if (strs[i] != null && strs[i].length() != 0) {
flag = true;
} else {
flag = false;
break;
}
}
}
return flag;
}
// 测试
public static void main(String[] args) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册