Tap here to switch tabs
Problem
Submissions

Problem: Sum of Scores of Built Strings

Try to solve the Sum of Scores of Built Strings problem.

Statement

You are building a string s of length n from right to left, one character at a time. For each ii from 11 to n, let sis_i denote the suffix of s of length ii.

The score of sis_i is defined as the length of the longest common prefix between sis_i and s.

Return the total sum of the scores across all sis_i for 1≤i≤n1 \leq i \leq n.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Scores of Built Strings

Try to solve the Sum of Scores of Built Strings problem.

Statement

You are building a string s of length n from right to left, one character at a time. For each ii from 11 to n, let sis_i denote the suffix of s of length ii.

The score of sis_i is defined as the length of the longest common prefix between sis_i and s.

Return the total sum of the scores across all sis_i for 1≤i≤n1 \leq i \leq n.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of lowercase English letters.