Preparando MOJI

K-Dominant Character

2000ms 262144K

Description:

You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.

You have to find minimum k such that there exists at least one k-dominant character.

Input:

The first line contains string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 100000).

Output:

Print one number — the minimum value of k such that there exists at least one k-dominant character.

Sample Input:

abacaba

Sample Output:

2

Sample Input:

zzzzz

Sample Output:

1

Sample Input:

abcde

Sample Output:

3

Informação

Codeforces

Provedor Codeforces

Código CF888C

Tags

binary searchimplementationtwo pointers

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:20:26

Relacionados

Nada ainda