# Palindrome Pairs

is taken from leetcode

Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.

Example 1:

Input: [“abcd”,”dcba”,”lls”,”s”,”sssll”]

Output: [[0,1],[1,0],[3,2],[2,4]]

Explanation: The palindromes are [“dcbaabcd”,”abcddcba”,”slls”,”llssssll”]

Example 2:

Input: [“bat”,”tab”,”cat”]

Output: [[0,1],[1,0]]

Explanation: The palindromes are [“battab”,”tabbat”]

My solution

``/**  * @param {string[]} words  * @return {number[][]}  */ var palindromePairs = function(words) {   const index = [];   for(let i = 0; i < words.length; i++) {     for (let j = 0; j < words.length; j++) {       if (i !== j) {         if (isPalindrome(words[i] + words[j])) { index.push([i, j]); }       }           }   }   return index; };  const isPalindrome = (word) => {   const len = word.length / 2 + 1;   const wordLength = word.length - 1;   for (let i = 0; i < len; i++){     if (word[i] !== word[wordLength - i]) {       return false;     }   }   return true; }; ``