# Number of distinct substrings

I know how to find the number of distinct substrings for a string (using suffix arrays) and I was wondering if there was a way to find this number for all of its prefixes.

I already have an $O(N^2)$ solution: computing the suffix array and lcp array for every prefix, but I would like a faster one.