Longest Palindrome by Concatenating Two Letter Words
A medium-tier problem at 54% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Databricks and 1 others.
You're facing a problem that looks deceptively simple: build the longest palindrome by concatenating two-letter words. Google and Databricks have both asked this. The trap is thinking you need complex palindrome logic. The real trick is recognizing that with two-letter words, you can pair matching letters greedily, and a single odd-count letter can sit in the middle. Half the candidates miss the greedy insight and overengineer it. If this hits your live assessment and you blank on the pairing strategy, StealthCoder surfaces the solution in seconds.
Companies that ask "Longest Palindrome by Concatenating Two Letter Words"
Longest Palindrome by Concatenating Two Letter Words is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe algorithm hinges on counting letter frequencies. Every two-letter word is a pair of the same letter (like 'aa') or two different letters. For matching pairs, you can use both. For mismatched pairs, you count how many of each letter you have across all words, then greedily build pairs. The key move: if you have odd counts, you can place one odd-count letter in the middle of the palindrome. Most candidates either try to validate palindromes on the fly (wasteful) or miss that you only need to count and pair greedily. The acceptance rate sits at 53 percent, meaning the insight isn't obvious under pressure. StealthCoder is your hedge if the counting-and-placement pattern doesn't click mid-assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Longest Palindrome by Concatenating Two Letter Words recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest Palindrome by Concatenating Two Letter Words interview FAQ
Why does greedy pairing work for this problem?+
With two-letter words, you're essentially working with character pairs. Greedy pairing maximizes the palindrome length because every valid pair contributes two characters symmetrically. The middle character (if any) is a bonus and doesn't break the palindrome property. No ordering preference exists.
How do I handle words with two different letters?+
Count the frequency of each letter across all words. A word with different letters (like 'ab') contributes one 'a' and one 'b' to your frequency map. Then pair them greedily. If you have 3 'a's and 2 'b's, you get 1 pair of 'a's, 1 pair of 'b's, plus one leftover 'a' for the middle.
Why is the acceptance rate only 53 percent?+
The greedy insight isn't intuitive. Candidates either overthink the palindrome validation, try to simulate concatenation, or miss that odd-count letters can occupy the center. The problem tests pattern recognition under time pressure, not coding complexity.
Is this problem still asked at Google and Databricks?+
Yes, both companies report asking it. It's a medium-difficulty problem that filters for candidates who think in terms of counting and pairing rather than brute-force construction. The acceptance rate and company data confirm it's still active in their loops.
What's the trap if I try to build and validate the palindrome string?+
You'll waste time and likely fail. The problem doesn't ask you to construct the actual string, just the maximum length. Counting and pairing is O(n). Building, reversing, and validating is slower and error-prone, especially under assessment pressure.
Want the actual problem statement? View "Longest Palindrome by Concatenating Two Letter Words" on LeetCode →