title: Find all anagrams in a string O(n) solution
body: <h2>Here is the problem:</h2>
  
  <p>Given a string <code>s</code> and a non-empty string <code>p</code>, find all the start indices of <code>p</code>'s anagrams in <code>s</code>.</p>
  
  <pre><code>Input: s: "cbaebabacd" p: "abc"
  Output: [0, 6]
  Input: s: "abab" p: "ab"
  Output: [0, 1, 2]
  </code></pre>
  
  <h1>Here is my solution</h1>
  
  <pre><code>vector&lt;int&gt; findAnagrams(string s, string p) {
      vector&lt;int&gt; res, s_map(26,0), p_map(26,0);
      int s_len = s.size();
      int p_len = p.size();
      if (s_len &lt; p_len) return res;
      for (int i = 0; i &lt; p_len; i++) {
          ++s_map[s[i] - 'a'];
          ++p_map[p[i] - 'a'];
      }
      if (s_map == p_map)
          res.push_back(0);
      for (int i = p_len; i &lt; s_len; i++) {
          ++s_map[s[i] - 'a'];
          --s_map[s[i - p_len] - 'a'];
          if (s_map == p_map)
              res.push_back(i - p_len + 1);
      }
      return res;
  }
  </code></pre>
  
  <p>However, I think it is O(n^2) solution because I have to compare vectors <code>s_map</code> and <code>p_map</code>.
  Does a O(n) solution exist for this problem? </p>