Skip to content

Commit 97be53a

Browse files
authored
Fixed SonarQube warnings
1 parent 0adccb9 commit 97be53a

File tree

15 files changed

+20
-20
lines changed

15 files changed

+20
-20
lines changed

src/main/java/g0001_0100/s0008_string_to_integer_atoi/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class Solution {
66
public int myAtoi(String str) {
7-
if (str == null || str.length() == 0) {
7+
if (str == null || str.isEmpty()) {
88
return 0;
99
}
1010
int i = 0;

src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public String longestCommonPrefix(String[] strs) {
1414
String temp = strs[0];
1515
int i = 1;
1616
String cur;
17-
while (temp.length() > 0 && i < strs.length) {
17+
while (!temp.isEmpty() && i < strs.length) {
1818
if (temp.length() > strs[i].length()) {
1919
temp = temp.substring(0, strs[i].length());
2020
}

src/main/java/g0001_0100/s0065_valid_number/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class Solution {
66
public boolean isNumber(String s) {
7-
if (s == null || s.length() == 0) {
7+
if (s == null || s.isEmpty()) {
88
return false;
99
}
1010
boolean eSeen = false;

src/main/java/g0201_0300/s0282_expression_add_operators/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class Solution {
1010
public List<String> addOperators(String num, int target) {
1111
List<String> res = new ArrayList<>();
12-
if (num.length() == 0 || Long.parseLong(num) > Integer.MAX_VALUE) {
12+
if (num.isEmpty() || Long.parseLong(num) > Integer.MAX_VALUE) {
1313
return res;
1414
}
1515
char[] list = num.toCharArray();

src/main/java/g0401_0500/s0434_number_of_segments_in_a_string/Solution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
public class Solution {
66
public int countSegments(String s) {
77
s = s.trim();
8-
if (s.length() == 0) {
8+
if (s.isEmpty()) {
99
return 0;
1010
}
1111
String[] splitted = s.split(" ");
1212
int result = 0;
1313
for (String value : splitted) {
14-
if (value.length() > 0) {
14+
if (!value.isEmpty()) {
1515
result++;
1616
}
1717
}

src/main/java/g0401_0500/s0468_validate_ip_address/Solution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Solution {
66
private static final String NEITHER = "Neither";
77

88
public String validIPAddress(String ip) {
9-
if (ip.length() == 0) {
9+
if (ip.isEmpty()) {
1010
return NEITHER;
1111
}
1212
String[] arr = ip.split("\\.", -1);
@@ -24,7 +24,7 @@ public String validIPAddress(String ip) {
2424
return "IPv4";
2525
} else if (arr1.length == 8) {
2626
for (String num : arr1) {
27-
if (num.length() < 1 || num.length() > 4) {
27+
if (num.isEmpty() || num.length() > 4) {
2828
return NEITHER;
2929
}
3030
for (int j = 0; j < num.length(); j++) {

src/main/java/g0401_0500/s0488_zuma_game/Solution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ private int dfs(String board, String hand) {
1616
}
1717

1818
private int findMinStepDp(String board, String hand, Map<String, Map<String, Integer>> dp) {
19-
if (board.length() == 0) {
19+
if (board.isEmpty()) {
2020
return 0;
2121
}
22-
if (hand.length() == 0) {
22+
if (hand.isEmpty()) {
2323
return -1;
2424
}
2525
if (dp.get(board) != null && dp.get(board).get(hand) != null) {

src/main/java/g0501_0600/s0520_detect_capital/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class Solution {
66
public boolean detectCapitalUse(String word) {
7-
if (word == null || word.length() == 0) {
7+
if (word == null || word.isEmpty()) {
88
return false;
99
}
1010
int upper = 0;

src/main/java/g0601_0700/s0664_strange_printer/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class Solution {
66
public int strangePrinter(String s) {
7-
if (s.length() == 0) {
7+
if (s.isEmpty()) {
88
return 0;
99
}
1010
int[][] dp = new int[s.length()][s.length()];

src/main/java/g0701_0800/s0761_special_binary_string/Solution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class Solution {
88
public String makeLargestSpecial(String s) {
9-
if (s == null || s.length() == 0 || s.length() == 2) {
9+
if (s == null || s.isEmpty() || s.length() == 2) {
1010
return s;
1111
}
1212
PriorityQueue<String> pq = new PriorityQueue<>((a, b) -> b.compareTo(a));
@@ -32,7 +32,7 @@ public String makeLargestSpecial(String s) {
3232
while (!pq.isEmpty()) {
3333
ans.append(pq.poll());
3434
}
35-
if (ans.length() == 0) {
35+
if (ans.isEmpty()) {
3636
ans.append('1');
3737
ans.append(makeLargestSpecial(s.substring(1, s.length() - 1)));
3838
ans.append('0');

0 commit comments

Comments
 (0)