FastPrepMerging Palindromes
Problems/Merging Palindromes

Merging Palindromes

Old Mission logoOld Mission● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Old Mission online assessment for a full-time role. The report names the task without repeating its statement. We followed the matching public exercise.

Our version is about 95% the same as the reported question.

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) → String

Examples

Example 1

first = "aabbc"second = "ddefefq"return = "abdefcfedba"

Use every available pair from both strings. Among the remaining odd-count letters, c is the smallest possible center, producing the lexicographically smallest maximum-length palindrome.

Example 2

first = "abc"second = "xyz"return = "a"

No character forms a pair in either string. A one-character palindrome is optimal, and a is lexicographically smallest.

Constraints

  • 1 <= first.length, second.length <= 200000
  • Both strings contain lowercase English letters only.

More Old Mission interview questions

  • Restricted JSON ParserPHONE SCREEN · Seen May 2025
  • Implement an Unordered MapPHONE SCREEN · Seen Dec 2022

Similar questions at other companies

  • Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
  • Viral Content BalancerTikTok · OATikTok interview questions
  • Find Minimum Time RequiredAmazon · OA
  • Largest Palindromic Number from Available DigitsMarshall Wace · OAMarshall Wace interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
  • Maximum String BeautyBank of America · OABank of America interview questions
  • Minimum Substrings Without Repeating CharactersMicrosoft · OAMicrosoft interview questions
  • Find Length of Longest Good SubsequenceWalmart · OAWalmart interview questions
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Rearrange a String So No Neighbors MatchThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions

Interview reports that mention this question

  • Old Mission Quant Trader and New Grad OA Questions: 7 Experiences
  • Old Mission SWE OA and Interview Questions: 14 Experiences

Old Mission interview experiences

  • Old Mission Junior Quant Trader OA Guide
See Old Mission hiring insights
Saved
class Solution {
    public String mergingPalindromes(String first, String second) {
      // Write your code here.
    }

}
Checking account…