[Solution] Matching Palindrome Round E Solution 2022 - Kick Start 2022
Problem
You are given a palindrome string of length consisting of only lowercase letters of the English alphabet. Find the shortest non-empty palindrome string such that concatenated with forms a palindrome. Formally, the string forms a palindrome.
Input
The first line of the input gives the number of test cases, . test cases follow. Each test case consists of two lines. The first line of each test case contains an integer denoting the length of the string . The second line of each test case contains a palindrome string of length .
Output
For each test case, output one line containing Case #:
, where is the test case number (starting from 1) and is the non-empty palindrome string as described above.
Limits
Memory limit: 1 GB.
.
String is a palindrome consisting of only lowercase letters of the English alphabet.
Test Set 1
Time limit: 20 seconds.
.
Test Set 2
Time limit: 40 seconds.
.
In Case 1, the shortest palindrome string is abba
such that the concatenation is abbaabba
which is a palindrome.
In Case 2, the shortest palindrome string is c
such that the concatenation is ccccc
which is a palindrome.
In Case 3, the shortest palindrome string is cdc
such that the concatenation is cdccdccdc
which is a palindrome.
No comments:
Post a Comment