ABCAAB in the text ABCABABABCAABABnext array values over the iteration of KMP - this table threw us under the bus (see the attachment). int i = 0, j = -1;else if (i < n && pattern[j] != text[i])this is why the next[j] is set to -1 " . we did not get this at all