Hi mohan. If I divide p_pwr[i] with a hash (instead of multiplying it on the other side), I get the wrong answer. What to do in the case where we don't have a choice of multiplying on the other side of eq. ? I am trying to use this hashing technique in "Repeated DNA Sequences" where there is no comparison of hash values (to multiply and compare). BTW, you are a great teacher. Thank you.
Division has to be with modulus. You have to use Fermat little theorem to convert division into multiplication first. If you are doing this already then there must be some bug in your code. The easiest way to try is to divide any number (say 5) by same number and see whether your code gives 1 as output or not. If you are still stuck, feel free to paste your code and I am happy to help you debug.
There are already few videos where I explained the theorem from scratch, try searching once (away from laptop now). If you don't find, let me know and I will try to find the link.
The way you started by breraking down the time complexity and tried optimizing the sub parts is simply amazing
You are a great teacher. Out support is always with you. ❤❤
Understood
Thanks a lot for the detailed explanation sir.
Thanks
Hi mohan. If I divide p_pwr[i] with a hash (instead of multiplying it on the other side), I get the wrong answer. What to do in the case where we don't have a choice of multiplying on the other side of eq. ? I am trying to use this hashing technique in "Repeated DNA Sequences" where there is no comparison of hash values (to multiply and compare). BTW, you are a great teacher. Thank you.
Division has to be with modulus. You have to use Fermat little theorem to convert division into multiplication first.
If you are doing this already then there must be some bug in your code. The easiest way to try is to divide any number (say 5) by same number and see whether your code gives 1 as output or not.
If you are still stuck, feel free to paste your code and I am happy to help you debug.
@@codingmohan could you please do a video on Fermit Little theorem? Thank you.
There are already few videos where I explained the theorem from scratch, try searching once (away from laptop now). If you don't find, let me know and I will try to find the link.
@@codingmohan I searched for "Fermat's little theorem by Coding Mohan". Nothing came. Please share the link if possible. Thank you.
th-cam.com/video/QB-X1ZJW-kE/w-d-xo.html
Excellent explanation bro 🔥🔥🔥 Btw what will be the codeforces rating for this question?
I guess 1200-1400
hello, why you use name mohan when your name is subham ?
also i am junior from your college; i came to know today itself man!
I just like the name Mohan and a friend of mine suggested this randomly and I didn't think again :)
@@codingmohannice man!