title: Number of substrings of a string with given count of each character
body: <p>Given a string (s) and an integer k, we need to find number of sub strings in which all the different characters occurs exactly k times.</p>
  <p>Example: s = &quot;aabbcc&quot;, k = 2
  Output : 6</p>
  <p>The substrings [aa, bb, cc, aabb, bbcc and aabbcc] contains distinct characters with frequency 2.</p>
  <p>The approach I can think of is to traverse through all sub strings and store frequency of current sub string, and increment the result when frequency equals k. This will result in worst case complexity of O(n*n), where n is the length of the string s.</p>
  <p>Is there any better approach for this problem?</p>