bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 336. Palindrome Pairs

336. Palindrome Pairs

Leetcode Solutions

Approach: Using a Trie

  1. Build a Trie by inserting the reverse of each word.
  2. For each word, check if its reverse is in the Trie (Case 1).
  3. For each word, check if there are any valid suffixes that are palindromes and if the remaining prefix is in the Trie (Case 2).
  4. For each word, check if there are any valid prefixes that are palindromes and if the remaining suffix is in the Trie (Case 3).
  5. Return the list of palindrome pairs found.
UML Thumbnail

Approach: Hashing

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...