Day: November 11, 2016
Find All Anagrams in a String
Problem:
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.
Solution:
Create a sliding window to compare. When compare the existence of lowercase letters, use ASICII codes as the index key in an array and store the existence # as the value. Use equals() method from java Array library to judge.