Skip to content
Back to libraryPart 4 · Advanced topics

4.5Selected string techniques

Before you start

It helps to have read 1.3 Arrays and strings, 1.4 Counting and frequency, 2.1 Prefix sums and 2.4 Recursion and backtracking. Overall level: Advanced.

Practice: Selected string techniques

0 of 4 solved

About these problems

Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.

  1. 1Prefix border lengthsFor every prefix s[1..i] of a lowercase string, print the length of its longest proper prefix that is also a suffix. A proper prefix is shorter than the whole current prefix.ApplyNot started
  2. 2All pattern startsFind all starting positions where pattern p occurs in text t. Include overlapping matches. Positions are 1-based.ConnectNot started
  3. 3Shortest repeating blockFind the minimum positive length k such that the string is an integer number of copies of its first k characters. One copy of the whole string is allowed.ReasonNot started
  4. 4Every full-string borderPrint all lengths k with 1<=k<|s| such that the first k characters equal the last k characters. Output lengths increasingly; the empty border and whole string are excluded.StretchNot started

Read the lesson