DataStructure: kmp fix array out of bound and delete array error