Comment

avatar username

we can do it with suffix array and lcp

imagine the lcp array form a histogram where the height is the length and the width is the frequency then if we used monotonic stack to get the prev greater, next greater we will be able to know for each substr how many times it exists

then for each length from 1 to lcp[i] it should has duplicates equal to the width in the histogram

The actual rating of this user is 1707.

Original comment.

Statistics