It is known that the length $L(x_1^n)$ of the longest block appearing at least twice in a randomly chosen sample path of length $n$ drawn from an i.i.d. process is asymptotically almost surely equal to $C \log n$, where the constant $C$ depends on the process. A simple coding argument will be used to show that for a class of processes called the finite energy processes, $L(x_1^n)$ is almost surely upper bounded by $C \log n$, where $C$ is a constant. While the coding technique does not yield the exact constant $C$, it does show clearly what is needed to obtain log $n$ bounds.
"String matching bounds via coding." Ann. Probab. 25 (1) 329 - 336, January 1997. https://doi.org/10.1214/aop/1024404290