during calculation of hash value in all the windows, why are we doing ((haystack[i + m - 1] - 'a') + MOD)? Like, what is the logic for using '+ MOD' instead of simply omitting MOD for that part or using '% MOD'? I had tried using '% MOD' since we use that everywhere, but that led to failure of a test case for LC 28
when you are recalculating the hashHay , we are subtracting a large value of (haystack[i-1]-'a') * 26^m and wee also %MOD a lot so the value will go to -ve in lot of cases so to balance it out we add MOD. if you want you can only %MOD at recalculation of hashHay and add MOD only if the hashHay value goes to -ve with a simple if condition, even this will work.
from where did you read this topic i want to learn from there ,i got the intuition but still for more clarity and good proof i want to know . please tell me .
Check the Algorithms course part 2 on coursera by Sedgewick. Its free to audit, and you will get the complete intuition and java code on this. I did it myself and re-wrote it in python. He doesnt talk about double hash though
Lmao. This guy said to use KMP for coding interviews because the "code is short", Bro, linear time Failure Function code is NOT intuitive and you cannot derive it by yourself! Not unless you either memorize or have 2 PhDs and 4 digit IQ.
The way you explain is just amazing
please upload z algorithm as well.
Please upload Z algorithm as well
after a long wait!!! thanks bro
Bhaiya maza aa gya... Legit peak content
How did you manage both full time job and TH-cam channel 😳
Neat and Clear Explanation.Thank you so much!!!😇
Aryan bro, please upload z - algorithm as well
Thank you for making this video. Double hashing is so cool.
Your explaination is too good.
wow , great explanation bro
bro please upload manachars algorithm i know it would be challenging but i believe you are the only one who are explain it to us on youtube
Beautiful explanation.
during calculation of hash value in all the windows, why are we doing ((haystack[i + m - 1] - 'a') + MOD)? Like, what is the logic for using '+ MOD' instead of simply omitting MOD for that part or using '% MOD'? I had tried using '% MOD' since we use that everywhere, but that led to failure of a test case for LC 28
when you are recalculating the hashHay , we are subtracting a large value of (haystack[i-1]-'a') * 26^m and wee also %MOD a lot so the value will go to -ve in lot of cases so to balance it out we add MOD.
if you want you can only %MOD at recalculation of hashHay and add MOD only if the hashHay value goes to -ve with a simple if condition, even this will work.
Finally ! Thanks bro.
Great explanation. Upload more algo vids
Good work bro
great work
amazing
Can someone specify, why are we taking the indices in reverse order and not in the usual order. Will the answer change if we do it in the usual order.
Answer will be same
BESSSSTTTTTESSSSSSSSSTTTTT EXPLAAANAATIIIIIIIIIOOOOOONNNNNNMNN !!!!!!!!!!!!!!!!!!
from where did you read this topic i want to learn from there ,i got the intuition but still for more clarity and good proof i want to know .
please tell me .
Check the Algorithms course part 2 on coursera by Sedgewick. Its free to audit, and you will get the complete intuition and java code on this. I did it myself and re-wrote it in python. He doesnt talk about double hash though
nice Explanation and can you share slides ?
Rabin-Karp, KMP, Trie - String Matching
40:13 xd😂😂
Please remove teams notification in yout laptop its traumatising me
🫡🫡🫡
Lmao. This guy said to use KMP for coding interviews because the "code is short", Bro, linear time Failure Function code is NOT intuitive and you cannot derive it by yourself! Not unless you either memorize or have 2 PhDs and 4 digit IQ.