educative.io

Educative

Hashfunction formula

what is the hash function formula that is used to solve DNA repeated sequence


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

hey @Sritharun_Telaprolu! Thanks for pointing out the issue.
To find the repeated DNA sequence in a string. To understand the rolling hash technique, consider the following example with the hash function:

H = c_1 a^{k-1} + c_2 a^{k-2} + … + c_i a^{k-i} + …+ c_{k-1} a^{1} + c_ka^{0}

Hash calculation formula has been added in the lesson. For a more profound view, please consider the following link: Solution: Repeated DNA Sequences - Grokking Coding Interview Patterns in Java.