Today we will try with a new algorithm – Z algorithm
This algo is used in pattern matching,there is another algo for pattern matching
This algorithm works in O(length of text+length of pattern) complexity
and space complexity is similar to time complexity that means O(length of text+length of pattern)
This algorithm is very easy.