Palindrome Pairs
Given a list of unique words, return all pairs of distinct indices (i, j) such that the concatenation of words[i] + words[j] is a palindrome.

30:00

Palindrome Pairs
hard
Topics
Companies

Given a list of unique words, return all pairs of distinct indices (i, j) such that the concatenation of words[i] + words[j] is a palindrome.

Example 1:
Input: {"words":["abcd","dcba","lls","s","sssll"]}
Output: [[0,1],[1,0],[3,2],[2,4]]
Constraints:
  • 1words.length50001 \leq \text{words.length} \leq 5000

  • 0words[i].length3000 \leq \text{words}[i].\text{length} \leq 300

  • words[i]\text{words}[i] consists of lowercase English letters.

  • All strings in words are unique.

Input
arr ={"words":["abcd","dcba","lls","s","sssll"]}

Build word map for 5 words

Words

abcd

[0]

dcba

[1]

lls

[2]

s

[3]

sssll

[4]
Palindrome Pairs Found (0)

No pairs found yet...

Words: 5
Pairs Found: 0
Variables
No variables to display
DepthFunction Call
Stack empty
0/10