Is it possible to count the number of distinct substrings in a string in O(n)?
<p>Given a string <code>s</code> of length <code>n</code>, is it possible to count the number of distinct substrings in <code>s</code> in O(n)?</p>

<p><strong>Example</strong></p>

<p>Input: <code>abb</code></p>

<p>Output: <code>5</code> (<code>'abb', 'ab', 'bb', 'a', 'b'</code>)</p>

<p>I have done some research but i can't seem to find an algorithm that solves this problem in such an efficient way. I know a O(n^2) approach is possible, but is there a more efficient algorithm?</p>

<p>I don't need to obtain each of the substrings, just the total number of distinct ones (in case it makes a difference).</p>