1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-20 22:17:09 +08:00

Merge pull request #410 from keepal7/master

fix : 最长公共前缀题目数组检测函数修复
This commit is contained in:
SnailClimb 2019-07-25 22:14:07 +08:00 committed by GitHub
commit bb4630cf4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,16 +135,20 @@ public class Main {
} }
private static boolean checkStrs(String[] strs) { private static boolean chechStrs(String[] strs) {
boolean flag = false;
if (strs != null) { if (strs != null) {
// 遍历strs检查元素值 // 遍历strs检查元素值
for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
if (strs[i] == null || strs[i].length() == 0) { if (strs[i] != null && strs[i].length() != 0) {
return false; flag = true;
} else {
flag = false;
break;
} }
} }
} }
return true; return flag;
} }
// 测试 // 测试