---
title: "336. Palindrome Pairs"
url: "https://laigary.com/interview/coding/336-palindrome-pairs"
type: "note"
section: "coding"
date: "2023-12-29"
updated: "2025-03-30"
tags: ["Palindrome"]
---

# 336. Palindrome Pairs

[336\. Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs/)

```python
class Solution:
    def palindromePairs(self, words: List[str]) -> List[List[int]]:
        
        def isPalindrome(word):
            left = 0
            right = len(word) - 1

            while left < right:
                if word[left] != word[right]:
                    return False
                left += 1
                right -= 1
            return True

        res = []
        i = 0
        
        while i < len(words):
            j = 0
            while j < len(words):
                if i != j:
                    word = words[i] + words[j]
                    if isPalindrome(word):
                        res.append([i, j])
                j += 1
            i += 1
        return res
```
