Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97be53a

Browse files
authored
Fixed SonarQube warnings
1 parent0adccb9 commit97be53a

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
publicclassSolution {
66
publicintmyAtoi(Stringstr) {
7-
if (str ==null ||str.length() ==0) {
7+
if (str ==null ||str.isEmpty()) {
88
return0;
99
}
1010
inti =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
Stringtemp =strs[0];
1515
inti =1;
1616
Stringcur;
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
publicclassSolution {
66
publicbooleanisNumber(Strings) {
7-
if (s ==null ||s.length() ==0) {
7+
if (s ==null ||s.isEmpty()) {
88
returnfalse;
99
}
1010
booleaneSeen =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
publicclassSolution {
1010
publicList<String>addOperators(Stringnum,inttarget) {
1111
List<String>res =newArrayList<>();
12-
if (num.length() ==0 ||Long.parseLong(num) >Integer.MAX_VALUE) {
12+
if (num.isEmpty() ||Long.parseLong(num) >Integer.MAX_VALUE) {
1313
returnres;
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
publicclassSolution {
66
publicintcountSegments(Strings) {
77
s =s.trim();
8-
if (s.length() ==0) {
8+
if (s.isEmpty()) {
99
return0;
1010
}
1111
String[]splitted =s.split(" ");
1212
intresult =0;
1313
for (Stringvalue :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
privatestaticfinalStringNEITHER ="Neither";
77

88
publicStringvalidIPAddress(Stringip) {
9-
if (ip.length() ==0) {
9+
if (ip.isEmpty()) {
1010
returnNEITHER;
1111
}
1212
String[]arr =ip.split("\\.", -1);
@@ -24,7 +24,7 @@ public String validIPAddress(String ip) {
2424
return"IPv4";
2525
}elseif (arr1.length ==8) {
2626
for (Stringnum :arr1) {
27-
if (num.length() <1 ||num.length() >4) {
27+
if (num.isEmpty() ||num.length() >4) {
2828
returnNEITHER;
2929
}
3030
for (intj =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
privateintfindMinStepDp(Stringboard,Stringhand,Map<String,Map<String,Integer>>dp) {
19-
if (board.length() ==0) {
19+
if (board.isEmpty()) {
2020
return0;
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
publicclassSolution {
66
publicbooleandetectCapitalUse(Stringword) {
7-
if (word ==null ||word.length() ==0) {
7+
if (word ==null ||word.isEmpty()) {
88
returnfalse;
99
}
1010
intupper =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
publicclassSolution {
66
publicintstrangePrinter(Strings) {
7-
if (s.length() ==0) {
7+
if (s.isEmpty()) {
88
return0;
99
}
1010
int[][]dp =newint[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
publicclassSolution {
88
publicStringmakeLargestSpecial(Strings) {
9-
if (s ==null ||s.length() ==0 ||s.length() ==2) {
9+
if (s ==null ||s.isEmpty() ||s.length() ==2) {
1010
returns;
1111
}
1212
PriorityQueue<String>pq =newPriorityQueue<>((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)

[8]ページ先頭

©2009-2025 Movatter.jp