Skip to content

Commit 1e4263a

Browse files
committed
Fixed style
1 parent 1376a52 commit 1e4263a

File tree

1 file changed

+8
-4
lines changed
  • src/main/java/g3301_3400/s3327_check_if_dfs_strings_are_palindromes

1 file changed

+8
-4
lines changed

src/main/java/g3301_3400/s3327_check_if_dfs_strings_are_palindromes/Solution.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ private void dfs(int x) {
2626
r[x] = ++now;
2727
}
2828

29-
private void manacher() {
29+
private void matcher() {
3030
c[0] = '~';
3131
c[1] = '#';
3232
for (int i = 1; i <= n; ++i) {
3333
c[2 * i + 1] = '#';
3434
c[2 * i] = stringBuilder.charAt(i - 1);
3535
}
3636
for (int i = 1, mid = 0, r = 0; i <= 2 * n + 1; ++i) {
37-
if (i <= r) p[i] = Math.min(p[(mid << 1) - i], r - i + 1);
38-
while (c[i - p[i]] == c[i + p[i]]) ++p[i];
37+
if (i <= r) {
38+
p[i] = Math.min(p[(mid << 1) - i], r - i + 1);
39+
}
40+
while (c[i - p[i]] == c[i + p[i]]) {
41+
++p[i];
42+
}
3943
if (p[i] + i > r) {
4044
r = p[i] + i - 1;
4145
mid = i;
@@ -57,7 +61,7 @@ public boolean[] findAnswer(int[] parent, String s) {
5761
dfs(0);
5862
c = new char[2 * n + 10];
5963
p = new int[2 * n + 10];
60-
manacher();
64+
matcher();
6165
boolean[] ans = new boolean[n];
6266
for (int i = 0; i < n; ++i) {
6367
int mid = (2 * r[i] - 2 * l[i] + 1) / 2 + 2 * l[i];

0 commit comments

Comments
 (0)