title: To find all the repeating substring in a given string
body: <p>I recetly come across an interview question : 
  To find all the repeating substring in a given string with a minimal size of 2.
  The algorithm should be efficient one.</p>
  
  <p>Code for above question is given below but it isn't efficient one.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;iterator&gt;
  #include &lt;set&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      typedef string::const_iterator iterator;
      string s("ABCFABHYIFAB");
      set&lt;string&gt; found;
  
      if (2 &lt; s.size())
          for (iterator i = s.begin() + 1, j = s.end(); i != j; ++i)
              for (iterator x = s.begin(); x != i; ++x)
              {
                  iterator tmp = mismatch(i, j, x).second;;
                  if (tmp - x &gt; 1)
                      found.insert(string(x, tmp));
              }
  
              copy(found.begin(), found.end(),ostream_iterator&lt;string&gt;(cout, "\n"));
  }
  </code></pre>
  
  <p>My question is that, is there any data structure which can implement above question in time 
  complexity of O(N)?</p>
  
  <p>If your answer is Suffix tree or Hashing please elaborate it.</p>