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

Commit2c6ee57

Browse files
authored
Update palindrome-partitioning-iv.cpp
1 parent0286ada commit2c6ee57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎C++/palindrome-partitioning-iv.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Solution {
66
boolcheckPartitioning(string s) {
77
constauto& P =manacher(s);
88
vector<int> prefix, suffix;
9-
for (int i =1; i <size(P) -1; ++i) {
9+
for (int i =2; i <size(P) -2; ++i) {
1010
if (i -1 - P[i] ==0) {
1111
prefix.emplace_back(i);
1212
}
@@ -16,6 +16,9 @@ class Solution {
1616
}
1717
for (constauto& i : prefix) {
1818
for (constauto& j : suffix) {
19+
if (left > right) {
20+
continue;
21+
}
1922
int left = i +1 + P[i], right = j -1 - P[j];
2023
int mid = left + (right - left) /2;
2124
if (P[mid] >= mid - left) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp