aboutsummaryrefslogtreecommitdiff
path: root/String
diff options
context:
space:
mode:
authorTa180m2019-09-04 13:49:18 -0500
committerGitHub2019-09-04 13:49:18 -0500
commit8ad47e9d3735a938d325609e8925c265fe755ac5 (patch)
tree57b64be134e02874b285353ac98616d6de682b93 /String
parent12181073dbbd4a3d7acc94695dc3525020a5ac03 (diff)
Update suffix_array.cpp
Diffstat (limited to 'String')
-rw-r--r--String/suffix_array.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/String/suffix_array.cpp b/String/suffix_array.cpp
index 434e6ba..7a989d2 100644
--- a/String/suffix_array.cpp
+++ b/String/suffix_array.cpp
@@ -1,8 +1,3 @@
-#include <algorithm>
-#include <vector>
-#include <string>
-using namespace std;
-
vector<int> suffix_array(string& S) {
int N = S.length();
vector<int> SA(N), rank(N);
@@ -21,8 +16,7 @@ vector<int> suffix_array(string& S) {
vector<int> cnt(N);
for (int i = 0; i < N; i++) cnt[i] = i;
for (int i = 0; i < N; i++) {
- int s = tmp[i] - t;
- if (s >= 0) SA[cnt[rank[s]]++] = s;
+ if (tmp[i] >= t) SA[cnt[rank[tmp[i] - t]]++] = tmp[i] - t;
}
}
return SA;