**QUESTION**

Text

Image

3. Merging Palindromes Given two strings, find all palindromes that can be formed with the letters of each string. From those palindromes, select one from each set that, when combined and rearranged, produces the longest palindrome possible. If there are multiple palindromes of that length, choose the alphabetically smallest of them. Example \[ \begin{array}{l} s 1=' a a b b c c^{\prime} \\ s 2=\text { 'ddefefq' } \end{array} \] All of the letters of the first string can make a palindrome. The choices using all letters are [abcba, bacab]. All of the letters of the second string can make a palindrome. The choices using all letters are [defqfed, dfeqefd, edfqfde, efdqdfe, fdeqedf, fedqdef]. The two longest results in 51 have a length of 5. The six longest results in s2 have a length of 6 . From the longest results for $s 1$ and $s 2$, merge the two that form the lowest merged palindrome,

$58 \mathrm{~m}$ left 3. Merging Palindromes Given two strings, find all palindromes that can be ALL formed with the letters of each string. From those palindromes, select one from each set that, when combined and rearranged, produces the longest palindrome possible. If there are multiple palindromes of that length, choose the alphabetically smallest of them. Example 2 \[ \begin{array}{l} s 1=' a a b b c^{\prime} \\ s 2=\text { 'ddefefq' } \end{array} \] 3 All of the letters of the first string can make a palindrome. The choices using all letters are [abcba, bacab]. All of the letters of the second string can make a palindrome. The choices using all letters are [defqfed, dfeqefd, edfafde, efdqdfe, fdeqedf, fedqdef]. The two longest results in st have a length of 5 . The six longest results in 52 have a length of 6 . From the longest results for 51 and $s 2$, merge the two that form the lowest merged palindrome, alphabetically. In this case, choose abcba and defqfed. The two palindromes can be combined to form a single palindrome if either the $c$ or the $q$ is discarded. The alphabetically smallest combined nalindrome is ahdefrfertha Type here to search

:1: Apps $58 \mathrm{~m}$ left Function Description Complete the function mergePalindromes in the editor below. The function must return a string. mergePalindromes has the following parameter(s): ALL string s1: a string string s2: a string Constraints - $1 \leq|\leq 1| \leq 10^{5}$ 1 - $1 \leq \mid \leq 2 / \leq 10^{5}$ - 51 and s2 will contain only lowercase English letters in the range asciil $a-2]$ 2 3 Input Format For Custom Testing The first line contains a string, s1. The second line contains a string, s2. Sample Case 0 Sample Input For Custom Testing STDIN Function $\mathrm{aab} \quad \rightarrow \mathrm{s} 1=\mathrm{Iab}^{\prime}$ cca $\rightarrow 52=' c{ }^{\prime} \mathrm{ca}^{\prime}$ Sample Output acaca Type here to search

Language JavaScript(Node.js) Autocomplete Ready (i) $1>$ 'use strict'; $26 / *$ 27 * Complete the 'mergePalindromes' function below. 28 * The function is expected to return a STRING. 30 * The function accepts following parameters: 31 * 1 . STRING 51 $32 \star 2$. STRING 52 $33 \quad * 1$ 35 function mergePalindromes(s1, s2) \{ 36 // Write your code here $\begin{array}{ll}37 \\ 38 & 3 \\ 39 & >\end{array}$ $39>$ function main() $[$... Test Results Custom Input

PLEASE SOLVE IN JAVASCRIPT, JAVA, PYTHON, or C++