Skip to content

Commit f9ca511

Browse files
author
alxkm
committed
fix Rule:CollapsibleIfStatements
1 parent 5e1d89d commit f9ca511

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/com/thealgorithms/strings/LongestPalindromicSubstring.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ public static String longestPalindrome(String s) {
1717
String maxStr = "";
1818
for (int i = 0; i < s.length(); ++i) {
1919
for (int j = i; j < s.length(); ++j) {
20-
if (isValid(s, i, j)) {
21-
if (j - i + 1 > maxStr.length()) { // update maxStr
22-
maxStr = s.substring(i, j + 1);
23-
}
20+
if (isValid(s, i, j) && (j - i + 1 > maxStr.length())) {
21+
maxStr = s.substring(i, j + 1);
2422
}
2523
}
2624
}

0 commit comments

Comments
 (0)