3 Palindrome
Problem Description
In this 3 Palindrome, Offered an input string word, divided the string right into specifically 3 palindromic substrings.
Functioning from left to right, pick the tiniest split for the very first substring that still permits the remaining word to be split into
2 palindromes.
Likewise, select the smallest 2nd palindromic substring that leaves a third palindromic substring.
If there is no way to split words right into precisely three palindromic substrings, print “Difficult” (without quotes).
Every character of the string needs to be eaten.
Situations not enabled–
After finding 3 palindromes using over guidelines, if any type of personality of the original string continues to be unconsumed.
[************************
] No character may be cooperated creating 3 palindromes.
[**************************
] Constraints
1
Input
Very first line contains the input string consisting of personalities between [a-z]
.
[****************************
] Outcome
Print 3 substrings one on each line. [
*************************]
Time frame
1
Instances
Example 1
Input
nayannamantenet
Result
nayan
naman
tenet
Description
The initial string can be split right into 3 palindromes as stated in the result.
Nonetheless, if the input was nayanamantenet, after that the solution would be “Difficult”.
Instance 2
Input
aaaaa
Result
a
a
aaa
Explanation
The other methods to divide the offered string right into 3 palindromes are as follows–
[a, aaa, a], [aaa, a, a], [aa, aa, a], etc.
Because we wish to lessen the size of the first palindromic substring utilizing entrusted to appropriate processing, the right means to split is [a, a, aaa]
Instance 3
Input
aaaabaaaa
Outcome
a
aaabaaa
a
Explanation
The various other ways to split the offered string right into 3 palindromes are as adheres to–
[aaaa, b, aaaa], [aa, aabaa, aa], and so on.
Considering that we wish to decrease the length of the initial palindromic substring utilizing left to appropriate processing, the correct way to split is [a, aaabaaa, a]
[sociallocker id=”766″] [/sociallocker]