Problem Statement | |||||||||||||
One of your friends has given you several words and asked you how many palindromic phrases you can compose with those words.
To save yourself some time, you've decided to write a program to answer this question. In this problem, a word is defined as a non-empty sequence
of lowercase letters ('a'-'z'). A phrase is a non-empty sequence of words, where each pair of consecutive words is separated with exactly one space character. A phrase is palindromic if it reads the same forward and backward, ignoring space characters.
You are given a String[] words. Return the number of different palindromic phrases that can be composed with the given words. Each word in words can be used at most once within each phrase. Two phrases are considered different if they are different strings, even if they read the same when ignoring spaces (for example, "a ba" and "ab a" are different phrases). | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | words will contain between 1 and 13 elements, inclusive. | ||||||||||||
- | Each element of words will contain between 1 and 13 lowercase letters ('a'-'z'), inclusive. | ||||||||||||
- | All elements of words will be distinct. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|