[Solution] Make Palindrome 2 CodeChef Solution
You are given a binary string of length . You want to obtain a palindrome from by applying the following operation at most times:
- Choose an index , delete the character from and concatenate the remaining parts of the string. Here denotes the current length of string .
For example, if 11010
, then applying the operation on index makes 1010
.
Note that after each operation, the length of the string decreases by one.
Find any palindrome you can obtain after the operations. It can be proved that it is always possible to obtain a palindrome from under the given constraints.
Here, denotes floor division of the integer by . For example, , . A binary string is a string that consists of only the characters 0
and 1
.
Input Format
- The first line of input contains an integer , denoting the number of test cases. The test cases
Passes for Fair CodeChef Solution
Fill Candies CodeChef Solution
Make Palindrome 2 CodeChef Solution
Fill The Grid CodeChef Solution
- then follow:
- The first line of each test case contains an integer , denoting the length of the binary string .
- The second line of each test case contains the binary string .
Output Format
For each test case, print on a separate line any palindromic string that can be obtained from by applying the given operation at most times.
Constraints
- contains only the characters
0
and1
.
No comments:
Post a Comment