educative.io

Can you guys simplify these examples

Seriously this is suppose to be about just sliding windows and arrays and now i have to figure out what is a sliding hash?


Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Repeated DNA Sequences - Grokking Coding Interview Patterns in Java

2 Likes

Hello @David_ChenFitzgerald,
I am sorry for the inconvenience caused by our side. Could you please clarify what your exact concern is? Are you not satisfied with the example problem given in the lesson?

Basically, the section is all about sliding windows " Solution: Repeated DNA Sequences - Grokking Coding Interview Patterns in Java". So what is a the rolling hash, how does it work, why should i use a rolling hash, it needs some better visuals or something in order to be less confusing to first timers.

HI, i also have some misunderstandings in that example.

  1. I dont figure out following statement:

    How did you come to the solution like this, like using a exponents here and decrementing exp’s, i dont get it.
    and why do we use the digit 4 ? i know cos there are 4 different numbers ? but how someone could come this solution, and especially, using this 4 value with exponents
    could you please clarify these,
  2. why do we use 4 exactly and how did you come to think that you need to use 4 here ?
  3. how did you come to the solution that we need to use an exp, and decrement it ?
    if those are the just solutions, ok im agree with it, but if there are some rules, please explain it just more.
    I know youre using them to save the order of the characters, but its not just easy to think that we need a 4 or count of distinct characters and decrement the exp every time.
    Thank you

I got the idea, after doing some research, this is rabin karp algorithm, and now i got the rule)
It would be better if you remind the names of algorithms, when you use them, thank you

1 Like

@Akmal_Nodirov @David_ChenFitzgerald
I found it confusing because they need to use the exact algorithm name. Rolling hash is a Rabin Karp algorithm that is used for searching/matching patterns in the text using a hash function.

1 Like