inception_95's blog

By inception_95, history, 6 years ago, In English

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.

  • Vote: I like it
  • -5
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem is, probably, because of this

may contain any ASCII characters with codes from 33 to 255

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 into unsigned char before use.