summaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
Diffstat (limited to 'string')
-rw-r--r--string/z.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/string/z.cpp b/string/z.cpp
index c128e9d..069fa38 100644
--- a/string/z.cpp
+++ b/string/z.cpp
@@ -1,10 +1,10 @@
vector<int> Z(const string& s) {
- int n = sz(s);
- vector<int> z(n);
- for (int i = 1, x = 0; i < n; i++) {
- z[i] = max(0, min(z[i - x], x + z[x] - i));
- while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
- x = i, z[i]++;
- }}
- return z;
+ int n = sz(s);
+ vector<int> z(n);
+ for (int i = 1, x = 0; i < n; i++) {
+ z[i] = max(0, min(z[i - x], x + z[x] - i));
+ while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
+ x = i, z[i]++;
+ }}
+ return z;
}