3 Palindrome Codevita 9 Solution

 3 Palindrome Codevita 9 Solution

Problem Description

Given an information string word, part the string into precisely 3 palindromic substrings. Working from left to right, pick the littlest split for the primary substring that despite everything permits the rest of the word to be part into 2 palindromes. 

Thus, pick the littlest second palindromic substring that leaves a third palindromic substring. 

In the event that it is extremely unlikely to part the word into precisely three palindromic substrings, print “Unthinkable” (without cites). Each character of the string should be devoured. 

 

Cases not permitted – 

Subsequent to discovering 3 palindromes utilizing above directions, if any character of the first string stays unconsumed. 

No character might be partaken in framing 3 palindromes. 

 

Requirements 

1 <= the length of information sting <= 1000 

 

Information 

First line contains the information string comprising of characters between [a-z]. 

 

Yield 

Print 3 substrings one on each line. 

 

Time Limit 

Models 

Model 1

Information 

nayannamantenet 

 

Yield 

nayan 

naman 

principle 

 

Clarification 

The first string can be part into 3 palindromes as referenced in the yield. 

Nonetheless, in the event that the information was nayanamantenet, at that point the appropriate response would be “Unthinkable”. 

 

Model 2 

Info 

aaaaa 

 

Yield 

aaa 

 

Clarification 

Different approaches to part the given string into 3 palindromes are as per the following – 

[a, aaa, a], [aaa, an, a], [aa, aa, a], and so forth. 

Since we need to limit the length of the first palindromic substring utilizing left to right preparing, the right method to part is [a, an, aaa]. 

 

Model 3 

Information 

aaaabaaaa 

 

Yield 

aaabaaa 

 

Clarification 

Different approaches to part the given string into 3 palindromes are as per the following – 

[aaaa, b, aaaa], [aa, aabaa, aa], and so on. 

Since we need to limit the length of the first palindromic substring utilizing left to right handling, the right method to part is [a, aaabaaa, a].

Codevita Season 9 All Questions Solutions

Listed Here :

Leave a Comment