TWICE  Twice
Given a string S, find the longest substring that appears at least twice in S (occurrences may overlap).
Input
The first line contains an integer L (1 ≤ L ≤ 200000), the length of S.
The second line contains the string S, consisting of exactly L lowercase letters ('a''z').
Output
Output the length of the longest substring that appears at least twice in S. If there is no such substring, output 0.
Example
Input:
11
sabcabcfabc
Output:
3
Input:
18
trutrutiktiktappop
Output:
4
hide comments
Ajey Golsangi:
20120905 17:32:24
Nice problem. 

Buda IM (retired):
20120225 22:59:20
Suffix array is not needed to solve this problem 

Nikhil Garg:
20101227 17:14:08
Too bad  I don't know O(N) construction of suffix tree yet :( 

Lovro Puzar:
20090824 14:52:50
> is substring of length 1 is also considered??

Added by:  Lovro Puzar 
Date:  20090821 
Time limit:  0.151s0.418s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Own problem 