MCPcopy Create free account
hub / github.com/atcoder/ac-library / z_naive

Function z_naive

test/unittest/string_test.cpp:35–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35std::vector<int> z_naive(std::vector<int> s) {
36 int n = int(s.size());
37 std::vector<int> z(n);
38 for (int i = 0; i < n; i++) {
39 while (i + z[i] < n && s[z[i]] == s[i + z[i]]) z[i]++;
40 }
41 return z;
42}
43
44TEST(StringTest, Empty) {
45 ASSERT_EQ(std::vector<int>{}, suffix_array(""));

Callers 1

TESTFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected