summaryrefslogtreecommitdiff
path: root/content/string/duval.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-08-23 21:36:51 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-08-23 21:36:51 +0200
commit961706d93af4daf58d5991deea88981a01f962b0 (patch)
treee1dd4163f3639b93de5795f1af0cc8ca0ce44232 /content/string/duval.cpp
parente1803aee4e150088b0865954de476edf182a9ffe (diff)
more stuff
Diffstat (limited to 'content/string/duval.cpp')
-rw-r--r--content/string/duval.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/content/string/duval.cpp b/content/string/duval.cpp
index bf36cce..253bae1 100644
--- a/content/string/duval.cpp
+++ b/content/string/duval.cpp
@@ -6,9 +6,8 @@ vector<pair<int, int>> duval(const string& s) {
if (s[k] < s[j]) k = i;
else k++;
}
- while (i <= k) {
+ for (; i <= k; i += j - k) {
res.push_back({i, i + j - k});
- i += j - k;
}}
return res;
}
@@ -16,6 +15,5 @@ vector<pair<int, int>> duval(const string& s) {
int minrotation(const string& s) {
auto parts = duval(s+s);
for (auto [l, r] : parts) {
- if (l < sz(s) && r >= sz(s)) {
- return l;
-}}}
+ if (r >= sz(s)) return l;
+}}