java.lang.Object
g0401_0500.s0467_unique_substrings_in_wraparound_string.Solution

public class Solution extends Object
467 - Unique Substrings in Wraparound String.<p>Medium</p> <p>We define the string <code>s</code> to be the infinite wraparound string of <code>&quot;abcdefghijklmnopqrstuvwxyz&quot;</code>, so <code>s</code> will look like this:</p> <ul> <li><code>&quot;...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....&quot;</code>.</li> </ul> <p>Given a string <code>p</code>, return <em>the number of <strong>unique non-empty substrings</strong> of</em> <code>p</code> <em>are present in</em> <code>s</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> p = &ldquo;a&rdquo;</p> <p><strong>Output:</strong> 1 Explanation: Only the substring &ldquo;a&rdquo; of p is in s.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> p = &ldquo;cac&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> There are two substrings (&ldquo;a&rdquo;, &ldquo;c&rdquo;) of p in s.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> p = &ldquo;zab&rdquo;</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> There are six substrings (&ldquo;z&rdquo;, &ldquo;a&rdquo;, &ldquo;b&rdquo;, &ldquo;za&rdquo;, &ldquo;ab&rdquo;, and &ldquo;zab&rdquo;) of p in s.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= p.length <= 10<sup>5</sup></code></li> <li><code>p</code> consists of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • findSubstringInWraproundString

      public int findSubstringInWraproundString(String p)