title: Algorithm - find all permutations of string a in string b
body: <p>Say we have
  string a = "abc"
  string b = "abcdcabaabccbaa"</p>
  
  <p>Find location of all permutations of a in b. I am trying to find an effective algorithm for this.</p>
  
  <p><strong>Pseudo code:</strong></p>
  
  <pre><code>sort string a // O(a loga)
  
  for windows of length a in b  // O(b)?
     sort that window of b      // O(~a loga)?
     compare to a
     if equal
        save the index
  </code></pre>
  
  <p>So would this be a correct algorithm? Run time would be around O(aloga + ba loga) ~= O(a loga b)? How efficient would this be? Possibly way to reduce to O(a*b) or better?</p>