java.lang.Object
g0401_0500.s0438_find_all_anagrams_in_a_string.Solution

public class Solution extends Object
438 - Find All Anagrams in a String.<p>Medium</p> <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of</em> <code>p</code><em>&rsquo;s anagrams in</em> <code>s</code>. You may return the answer in <strong>any order</strong>.</p> <p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;cbaebabacd&rdquo;, p = &ldquo;abc&rdquo;</p> <p><strong>Output:</strong> [0,6]</p> <p><strong>Explanation:</strong></p> <pre><code> The substring with start index = 0 is &quot;cba&quot;, which is an anagram of &quot;abc&quot;. The substring with start index = 6 is &quot;bac&quot;, which is an anagram of &quot;abc&quot;. </code></pre> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abab&rdquo;, p = &ldquo;ab&rdquo;</p> <p><strong>Output:</strong> [0,1,2]</p> <p><strong>Explanation:</strong></p> <pre><code> The substring with start index = 0 is &quot;ab&quot;, which is an anagram of &quot;ab&quot;. The substring with start index = 1 is &quot;ba&quot;, which is an anagram of &quot;ab&quot;. The substring with start index = 2 is &quot;ab&quot;, which is an anagram of &quot;ab&quot;. </code></pre> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length, p.length <= 3 * 10<sup>4</sup></code></li> <li><code>s</code> and <code>p</code> consist of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details