Card Game
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Recently we had the opportunity to observe a rare phenomenon. A blue blood supermoon — definitely an unforgettable sight. Of course, our old friend the romantic Zenyk could not miss such an opportunity to impress Marichka. So he invited her home and talked about an amazing surprise waiting for her at night.
However, Marichka stubbornly refused to stay for the night. And Zenyk came up with a way to interest her. He found a deck of \(n\) cards. On each card, a lowercase letter of the Latin alphabet was written. Marichka’s task is to form the longest possible palindrome from the available cards.
Palindrome — is a string that reads the same forwards and
backwards. For example, the strings a, aba,
pwwp are palindromes, while the strings ab,
abc, aabb are not.
Input
The first line contains an integer \(n\) — the number of cards.
The second line contains \(n\) lowercase Latin letters \(c_i\) — the letter written on the \(i\)-th card.
Output
Print a single line — the longest palindrome that can be formed from the letters written on the cards. If there are several such strings, print any of them.
Constraints
\(1 \le n \le 10^3\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 a b c c z b w | bczcb |
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 |
|---|