After watching this video Algorithms Live! Episode 3 — Rolling Hashes and Bloom Filters, I tried to implement pull character from last by myself and applying it on this problem here:
Problem: 1423. String Tale
Code : My code
Is my implementation wrong? if so, what is wrong in this? or can anyone give a code that works like the same principle as the video and works perfectly?
Thanks in advance.
Problem is, probably, because of this
So for characters with codes more than 127, their
char
values will be < 0. And you don't take this into account, when you take modulo of products with these values. Just cast all codes intounsigned char
before use.