Marks :50
: 4 | : 0
A string is called a palindrome string if the reverse of the string is same as the original string.
A string $$$S$$$ is called an extended palindrome string if the string becomes a palindrome after chucking it in chunks of length $$$d$$$, where $$$d$$$ is either 1 or a prime divisor of $$$|S|$$$, where $$$|S|$$$ is the length of the string. For example, 'abcxyzabc' is not a palindrome but an extended palindrome as it can be broken as {abc}{xyz}{abc} into chunks of length 3.
The degree of a string is defined as the minimum possible chunk length that can make the string an extended palindrome.
Given a string $$$S$$$, find its degree.
The first line of input consists of a string $$$S$$$ $$$-$$$ $$$(1 \leq |S| \leq 10^5)$$$.
Output a single integer - the degree of the string $$$S$$$. In case there is no possible chunk length that can make the string an extended palindrome, output -1.
abba
1
abcxyzabc
3
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.