added solution for longest repetition problem