3820.You're Given a String

Time Limit: 1s Memory Limit: 256MB

You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).

Input Format(From the terminal/stdin)

The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.

Output Format(To the terminal/stdout)

Output one number - length of the longest substring that can be met in the string at least twice.

Sample Input 1

Copy
abcd
    \n

Sample Output 1

Copy

\n

Sample Input 2

Copy
ababa
     \n

Sample Output 2

Copy
3
 \n

Sample Input 3

Copy
zzz
   \n

Sample Output 3

Copy
2
 \n

Submit

请先 登录

© 2025 FAQs