We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a0992a commit 0bcda05Copy full SHA for 0bcda05
src/main/java/com/fishercoder/solutions/_1745.java
@@ -16,20 +16,20 @@ public boolean checkPartitioning(String s) {
16
for (int i = n - 1; i >= 0; i--) {
17
for (int j = i; j < n; j++) {
18
if (s.charAt(i) == s.charAt(j)) {
19
- dp[i][j] = (i + 1 < j - 1) ? dp[i + 1][j - 1] : true;
+ dp[i][j] = (i + 1 <= j - 1) ? dp[i + 1][j - 1] : true;
20
} else {
21
dp[i][j] = false;
22
}
23
24
25
for (int i = 1; i < n - 1; i++) {
26
- for (int j = 1; j < n - 1; j++) {
+ for (int j = i; j < n - 1; j++) {
27
if (dp[0][i - 1] && dp[i][j] && dp[j + 1][n - 1]) {
28
return true;
29
30
31
32
- return true;
+ return false;
33
34
35
0 commit comments