KMP String matching pattern algorithm

Note: If you understand above transition then rest is easy.