Solution for exact string match using Z algorithm