This is cheating, implement KMP algorithm.