Add code:KMP method