Dashboard
LC #336

Palindrome Pairs

Pattern · ?GoogleAmazonBloombergUber

Problem

Find all pairs of indices (i, j) such that words[i] + words[j] is a palindrome.

Constraints

  • 1 ≤ words.length ≤ 5000
  • 0 ≤ words[i].length ≤ 300
  • words[i] consists of lowercase letters
  • All words are unique

Example

Input
words = ["abcd","dcba","lls","s","sssll"]
Output
[[0,1],[1,0],[3,2],[2,4]]
Why
"abcddcba","dcbaabcd","slls","llssssll" are all palindromes

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗