I was asked the following question in the online interview:
Given 2 strings 'A' & 'B', find whether it is possible to cut both strings at a common point such that
concatenating the first part of one string and the second part of the other string results in a palindrome.
Example 1:
Input: A = "abcdef" B = "xyzcba"
Output: true -> as we can cut both the string from index 2 to get the palindromic string "abccba"
Example 2:
Input: A = "abcxxxdef" B = "abcabccba"
Output: true -> as we can cut both the string from index 5 to get the palindromic string "abcxxxcba"
Follow up question:
Instead of cutting at the same point, you can now cut at different points (and
do the same operation of concatenating first part of one string with the second part of the other).
What is the length of the longest palindrome that can be formed this way?