Company: Zscalar_16nov
Difficulty: medium
Merging Palindromes Problem Description Given two strings: - Identify all palindromes that can be formed using each string's letters. - Select one palindrome from each set that, when combined and possibly rearranged, creates the longest possible palindrome. - Return the combined palindrome. - If multiple palindromes of the maximum length exist, return the alphabetically smallest one. Examples Example 1: Input: s1 = "aabbc", s2 = "ddeefq" Output: "abdefcfedba" Explanation: - From s1, we can form palindromes using all letters: ["abcba", "bacab"] - From s2, we can form palindromes using all letters: ["defqfed", "dfedqfd", "edqdfqe", "fedqdef"] - To form the combined palindrome: - Choose "abcba" from s1 and "defqfed" from s2 (alphabetically smallest options) - To form a single palindrome, either 'c' or 'q' must be discarded - The alphabetically smallest combined palindrome is "abdefcfedba" Example 2: Input: s1 = "adaab", s2 = "cca" Output: "aaccaa" Explanation: - From s1, "aaa" - From s2,