@@ -0,0 +1,970 @@
+import unittest%0A%0A_a = ord('a')%0A%0A%0Aclass Solution(object):%0A    def findAnagrams(self, s, p):%0A        %22%22%22%0A        :type s: str%0A        :type p: str%0A        :rtype: List%5Bint%5D%0A        %22%22%22%0A        np = len(p)%0A        ret = %5B%5D%0A        cp = %5B0%5D * 26%0A        for ch in p:%0A            cp%5Bord(ch) - _a%5D += 1%0A        cs = %5B0%5D * 26%0A        for ch in s%5B:np%5D:%0A            cs%5Bord(ch) - _a%5D += 1%0A        if cs == cp:%0A            ret.append(0)%0A        lo = 0%0A        for hi in xrange(np, len(s)):%0A            cs%5Bord(s%5Blo%5D) - _a%5D -= 1%0A            cs%5Bord(s%5Bhi%5D) - _a%5D += 1%0A            lo += 1%0A            if cs == cp:%0A                ret.append(lo)%0A        return ret%0A%0A%0Aclass Test(unittest.TestCase):%0A    def test(self):%0A        self._test('cbaebabacd', 'abc', %5B0, 6%5D)%0A        self._test('abab', 'ab', %5B0, 1, 2%5D)%0A%0A    def _test(self, s, p, expected):%0A        actual = Solution().findAnagrams(s, p)%0A        self.assertEqual(actual, expected)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

438. Find All Anagrams in a String. Array counting, sliding window substring