19.4k views
1 vote
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.

User JazzyP
by
8.4k points

1 Answer

4 votes

Final answer:

The student is asking how to find the starting indices of all anagrams of a given string p within another string s, focusing on efficient solutions suitable for long strings of up to 20,100 characters.

Step-by-step explanation:

The question asks how to find all the start indices of a given non-empty string p's anagrams in another string s. The task involves checking each substring of s that has the same length as p, and determining if it is an anagram of p. This can be done by comparing sorted versions of the substring and p, or by using a frequency count of the characters. Since the strings consist of lowercase English letters and the lengths are limited to 20,100, efficient methods need to be used to handle large strings. The indices are the positions in string s where the anagrams start.

User Kenial
by
8.7k points