- When solving this problem: http://www.codechef.com/problems/MARCHA6, I got an issue, that is: Let 2 binary strings A and B. With every index i of string A, calculate the max matching of string starting from i and string B. For example:
- A= 1 0 1 1 0 0 1 1 1 0
- B= 0 1 1 1 0 1
- with i= 1 -> max matching= 0
- i= 2 -> max matching= 3 (it is '0 1 1')
- i= 3 -> max matching= 0
- i= 4 -> max matching= 0
- i= 5 -> max matching= 1 (it is '0')
- Could anyone tell me how to solve it in O(n)?
Thank you! Sorry for my poor English.
http://codeforces.net/blog/entry/3107
Oh, thanks a lot! This is what I need!
You didn't know about Z-algorithm before? Oo
How?
Z algorithm is not popular in Vietnam. We only know KMP