Problem · String
Merging Palindromes
Learn this problemProblem statement
From the letters of first, choose a multiset that can be rearranged into a palindrome. Do the same independently for second. Combine the two chosen multisets and rearrange them into one palindrome.
Return the longest palindrome obtainable this way. If several have maximum length, return the lexicographically smallest.
Function
mergingPalindromes(first: String, second: String) → StringExamples
Example 1
first = "aabbc"second = "ddefefq"return = "abdefcfedba"Use all available pairs and the smallest usable center. The result has maximum length and is alphabetically smallest among those results.
Constraints
1 <= first.length, second.length <= 200000- Both strings contain lowercase English letters only.
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024