All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0401_0500.s0467_unique_substrings_in_wraparound_string.readme.md Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
467\. Unique Substrings in Wraparound String

Medium

We define the string `base` to be the infinite wraparound string of `"abcdefghijklmnopqrstuvwxyz"`, so `base` will look like this:

*   `"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd...."`.

Given a string `s`, return _the number of **unique non-empty substrings** of_ `s` _are present in_ `base`.

**Example 1:**

**Input:** s = "a"

**Output:** 1

**Explanation:** Only the substring "a" of s is in base.

**Example 2:**

**Input:** s = "cac"

**Output:** 2

**Explanation:** There are two substrings ("a", "c") of s in base.

**Example 3:**

**Input:** s = "zab"

**Output:** 6

**Explanation:** There are six substrings ("z", "a", "b", "za", "ab", and "zab") of s in base.

**Constraints:**

*   1 <= s.length <= 105
*   `s` consists of lowercase English letters.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy