Google | Phone Screen | L5

Google Phone Screen Question: Only one question and its as follows:

Given an array of X strings in which each string consists of two lowercase English letters, join as many strings together as possible in order to obtain a palindrome.

Input: arr = ["ck", "kc", "ho", "kc"]
Output: 4

explanation being that the longest palindrome are "ckkc" and "kcck" which both have lengths of 4.

This was the only question, and I found it rather difficult at first but all the needs to happen is iterate over the array, for each of the strings in lowercase letters, if the count of the reversed string is greater than 0, we can ise this pair of strings to extend the palindrome.

FYI: Found this question very similar to LC 2131

Comments (20)