Implementing suffix array

Given a string S[1…n] and l where l is an integer less than n then how can we efficiently construct the function f(n) (please see below for more explanation)
for every string S[i,j] where
j-i=l

f(n) denotes the longest longest suffix which is also the prefix of a string.

prefix of string S[1…N] or S[i,j] ??