Finding a palindrome
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk has a string \(s\) of length
\(n\), where each character is either
0 or 1. Zenyk can delete characters from the
string \(s\), but exams are coming soon
and little time is left, so he can delete at most half of the
characters.
Marichka likes palindromes — strings that read the same from left to right and from right to left.
Help Zenyk delete at most half of the characters so that the final string pleases Marichka (i.e., is a palindrome).
Input
The first line contains a positive integer \(n\) — the length of the string.
The second line contains \(s\) — the string from which characters need to be deleted.
Output
Output the final string after deleting at most half of the characters.
Constraints
\(1 \le |s| \le 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 01 | 1 |
| Input (stdin) | Output (stdout) |
|---|---|
| 3 010 | 010 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|