Sum of Scores of Built Strings
HardLeetCodeString Algorithms (KMP, Z, Hashing)
Approach hintTry it first, then revealHide
The score of each built string is the longest common prefix of a suffix of s with s itself, which is exactly the Z-function. Sum the Z-values and remember the full string, whose score is n.