# Leetcode 467 - Unique Substrings in Wraparound String

`Note:`

- First, for a substring with length
`k`

, how many substrs does it have?- It’s
`1 + 2 + 3 + ... + k`

;

- It’s
- The tricky part is how to avoid repetitve calculations. Like
`p = abcab`

,`abc`

includes`ab`

, so we should only count`abc`

once. - We should know that because
`abc`

is`longer`

than`ab`

, we should skip`ab`

, which means for each char, we need to document the`longest substr starting with ch`

! - Mark the longest substr in
`count[]`

with length 26. - Use
`double pointers`

to find the longest continuously increasing sequences starting with`p[left]`

. - Then we have a
`len`

. And by increasing`left`

, we compare`count[left]`

with`right - left + 1`

. - If
`right - left + 1 > count[left]`

, it means we should update count[ch]. - In the end, add up all char’s length together from
`count[]`

.

`Question:`

We define the string `s`

to be the infinite wraparound string of “`abcdefghijklmnopqrstuvwxyz`

“, so s will look like this:

- “…zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd….”.

Given a string `p`

, return the number of `unique non-empty substrings`

of `p`

are present in `s`

.

`Example:`

1 | Input: p = "a" |

`Code:`

1 | /** |