how to insert words in hashmaps and further search in hashmap for just a portion of a word
Unique words pairs
implementation is bit tricky, but actually straightforward. See you understood that we have to find prefixes of each string among other strings, right, and then simply linearly check whether the left over part is palindrome. So, one idea is, put all strings in a set, for each string, exclude it from set(so that you don’t match it with itself) and then for each prefix of this string, find whether it exists in set, if yes, check whether the left-over part of the string you picked is palindrome, if both conditions are true, increment the answer and insert this string back into set(because it can be paired with other strings as well).
You can look in leetcode discuss if you want the code. https://leetcode.com/problems/palindrome-pairs/