Tap here to switch tabs
Problem
Submissions

Problem: Sum of Scores of Built Strings

Sum of Scores of Built Strings asks you to compare every suffix of a given string, find each longest common prefix, and return their total length.

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

Sum of Scores of Built Strings asks you to compare every suffix of a given string, find each longest common prefix, and return their total length.

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.