Z Algorithm

Please could anyone explain the O(n) method of Z Array computation. I understood what it is but could not understand how to code it properly. Could anyone help me ? I studied it from codeforces.

Link

Read this [z-algo][1]
[1]: Advanced searching via Z-Algorithm

HERE:

Advanced searching via Z-Algorithm

I used this link already for understanding the concept…Thank you…but didn’t understood the code