Tag Archives: palindrome

Palindrome Pairs

Leetcode 336. 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: Given words = [“bat”, “tab”, “cat”] Return [[0, 1], [1, 0]] The palindromes are [“battab”, “tabbat”] Example 2:… Read More »

Palindrome Permutation II

This one is from leetcode. Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. For example: Given s = “aabb”, return [“abba”, “baab”]. Given s = “abc”, return []. Solution. We should get string where each unique char is only… Read More »