summaryrefslogtreecommitdiff
path: root/sonstiges/LCSOS.cpp
diff options
context:
space:
mode:
authorJBatzill <batzilljohannes@gmail.com>2014-11-20 15:35:18 +0100
committerJBatzill <batzilljohannes@gmail.com>2014-11-20 15:35:18 +0100
commit6a062d45137b95cd550ea79d97deceefd0a75ac6 (patch)
tree60aa8691ca951a549988c3d2690a274417276515 /sonstiges/LCSOS.cpp
parent1053eaa33bf30c46549188f559d59edcd200d0a5 (diff)
Rename LCSOS.cpp to SufixArray.cpp
Diffstat (limited to 'sonstiges/LCSOS.cpp')
-rw-r--r--sonstiges/LCSOS.cpp22
1 files changed, 0 insertions, 22 deletions
diff --git a/sonstiges/LCSOS.cpp b/sonstiges/LCSOS.cpp
deleted file mode 100644
index 103e503..0000000
--- a/sonstiges/LCSOS.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//longest common substring in one string (overlapping not excluded)
-string lsubs(string s) {
- if(s.length() == 0) return "";
- vector<int> a(s.length());
- for(int k = 0; k < a.size(); k++) a[k] = k;
- sort(a.begin(), a.end(), [&] (const int &u, const int &l) {
- int ui = u, li = l;
- while(ui < s.length() && li < s.length()) {
- if(s[ui] < s[li]) return true;
- else if(s[ui] > s[li]) return false;
- ui++; li++;
- }
- return !(ui < s.length());
- });
- int r = 0, m=0, c=0;
- for(int i = 0; i < a.size() - 1; i++) {
- c = 0;
- while(a[i]+c < s.length() && a[i+1]+c < s.length() && s[a[i]+c] == s[a[i+1]+c]) c++;
- if(c > m) r=i, m=c;
- }
- return m == 0 ? "" : s.substr(a[r], m);
-}