"""Leetcode 438. Find All Anagrams in a String
Medium

URL: https://leetcode.com/problems/find-all-anagrams-in-a-string/

Given a string s and a non-empty string p, find all the start indices of p's
anagrams in s.

Strings consists of lowercase English letters only and the length of both strings
s and p will not be larger than 20,100.

The order of output does not matter.

Example 1:
Input:
s: "cbaebabacd" p: "abc"
Output:
[0, 6]
Explanation:
The substring with start index = 0 is "cba", which is an anagram of "abc".
The substring with start index = 6 is "bac", which is an anagram of "abc".

Example 2:
Input:
s: "abab" p: "ab"
Output:
[0, 1, 2]
Explanation:
The substring with start index = 0 is "ab", which is an anagram of "ab".
The substring with start index = 1 is "ba", which is an anagram of "ab".
The substring with start index = 2 is "ab", which is an anagram of "ab".
"""

class Solution(object):
    def findAnagrams(self, s, p):
        """
        :type s: str
        :type p: str
        :rtype: List[int]

        Time complexity: O(m*n), where m & n is length of s & p.
        Space complexity: O(1).
        """
        pass


def main():
    # Output: [0, 6]
    s = "cbaebabacd"
    p = "abc"
    print Solution().findAnagrams(s, p)

    # Output: [0, 1, 2]
    s = "abab"
    p = "ab"
    print Solution().findAnagrams(s, p)


if __name__ == '__main__':
    main()

@@ -896,16 +896,42 @@
 Solution
+CharCountListSlidingWindow
 (object)
@@ -932,16 +932,16 @@
 bject):%0A
-
     def 
@@ -1168,12 +1168,1094 @@
     
-pass
+# Edge case.%0A        if not s or len(s) %3C len(p):%0A            return %5B%5D%0A%0A        result = %5B%5D%0A%0A        len_p = len(p)%0A        len_s = len(s)%0A%0A        # Create array of length 26 to aggregate char's count for p.%0A        p_char_counts = %5B0%5D * 26%0A        for i in range(len_p):%0A            p_char_counts%5Bord(p%5Bi%5D) - ord('a')%5D += 1%0A%0A        # Apply sliding window for s of length p to get char's count.%0A        s_char_counts = %5B0%5D * 26%0A        %0A        # Initalize 1st sliding window's prefix for s w/o last char of p.%0A        for i in range(len_p - 1):%0A            s_char_counts%5Bord(s%5Bi%5D) - ord('a')%5D += 1%0A%0A        for i in range(len_p - 1, len_s):%0A            # Increment by RHS char of sliding window of s.%0A            s_char_counts%5Bord(s%5Bi%5D) - ord('a')%5D += 1%0A%0A            # Decrement by LHS char of sliding window of s.%0A            if i - len_p %3E= 0:%0A                s_char_counts%5Bord(s%5Bi - len_p%5D) - ord('a')%5D -= 1%0A%0A            if s_char_counts == p_char_counts:%0A                # Append start index of sliding window.%0A                result.append(i - len_p + 1)%0A%0A        return result
 %0A%0A%0Ad
@@ -2331,32 +2331,58 @@
   print Solution
+CharCountListSlidingWindow
 ().findAnagrams(
@@ -2436,24 +2436,24 @@
    p = %22ab%22%0A
-
     print So
@@ -2458,16 +2458,42 @@
 Solution
+CharCountListSlidingWindow
 ().findA

Complete char count sliding window sol w/ time/space complexity