Find All Anagrams in a String

Posted on

Screen Shot 2016-11-10 at 4.12.34 PM.png


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.


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.








Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s