I am glad you liked it . It was written in a rush though XD
Good questionâŚ
With âabaabaabaâ the answer is 3 and with âabaabaabaabaabaâ the answer is 5. Using more than three letters is also possible. With âcbabccbabccbabcâ we get 3.
Thank you oconnor_robert
I am terrible at coming up with test cases. How do you do it? Did you write a program to generate cases?
My first thought was âababaâ. That fails because the aâs at either end up next to each other. From that observation I realised that we need to double the other aâs. Another way to think about it is using your observation. For s = âaaaaâ we get 4. If we replace each âaâ with a palindrome, we will always get at least 4.
Nice work broâŚ
âabbaabbaâ is also interesting and gives 4. This is different than my other examples because there are two unique palindromes that can be formed by shifting this one: âabbaabbaâ and âbaabbaabâ.
wow, this is amazing! Thank you again
Just to make our lives easier.
These factors depend strictly on your hash function. Check what the setter and tester have done, they did something different. They made it such that, instead of checking if hsh is a multiply of hsh2 or not, they simply checked for hsh1==hsh2. Give a read to editorial if they havent. Try to get what is represented by the hash function, it will be easier to understand it.
Editorial solution is expected to be put up so that we can relate with the editorial. Setter solution has been poorly explained and I couldnât get the logic behind the setterâs code.
Could you please tell me the logic behind setterâs code?
What do you mean by "Setter solution has been poorly explained"
. What did you not understand?
I feel the concept is quite sufficiently explained and is easy to understand. Dry run a few iterations to understand.
Editorial solution is expected to be put up so that we can relate with the editorial.
-_- . The editorial explains setterâs and testerâs solution. What do I do then, copy paste setters code?
Could you please tell me the logic behind setter's code?
If such big editorial couldnt help you, I doubt my comment will. Please give more efforts before blaiming.
I still dont understand why do we need to conider n+1 to 3*n-1 range and make increments of 2 while counting the ans ?