Skip to content

Commit b4010be

Browse files
authored
Update palindrome-partitioning-iv.cpp
1 parent 4c7cbcb commit b4010be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

C++/palindrome-partitioning-iv.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ class Solution2 {
6565
}
6666
}
6767
for (int i = 1; i + 1 < size(s); ++i) {
68+
if (!dp[0][i - 1]) {
69+
continue;
70+
}
6871
for (int j = i + 1; j < size(s); ++j) {
69-
if (dp[0][i - 1] && dp[i][j - 1] && dp[j][size(s) - 1]) {
72+
if (!dp[j][size(s) - 1]) {
73+
continue;
74+
}
75+
if (dp[i][j - 1]) {
7076
return true;
7177
}
7278
}

0 commit comments

Comments
 (0)