CT006

Mirror Word Pairing

HardAcceptance: 0.0%

The Codetikki loremasters seek pairs of words that, when stitched together, form a perfect mirror (palindrome). Given a list of words, find all pairs of unique indices (i, j) such that the concatenation of the two words is a palindrome.

Example 1:

Input: 4 code edoc da d
Output: (0,1) (1,0) (2,3)

Example 2:

Input: 3 abc cba a
Output: (0,1) (1,0) (0,2) (1,2) (2,0) (2,1)

Constraints:

1 <= n <= 5000 1 <= word length <= 300 Words consist of lowercase English letters

Tags:

strings hash-table trie
Loading...
Test Cases:No test cases
No test cases available.