We can find out the total number of distinct substrings in the string by substracting the LCP (longest common prefix) of the suffix at each index with the suffix at the previous index.
Can someone help me in proving this?
Thanks in advance
Happy Coding
Here is an article explaining the logic behind the method: e-maxx-eng — Suffix Array. It's not too long, but I think it should be enough.