← Questions
Palindrome pairs
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Given a list of distinct words, return every pair of indices (i, j) where words[i] + words[j] is a palindrome. Checking all pairs is too slow; put the reversed words in a hash map (or a trie) and for each word try each split into a prefix and suffix, looking for the missing reversed piece when the other part is a palindrome.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
