Problem Statement
A palindrome is a string of length 1 (one) or greater that is the same both forwards and backwards. Examples are "AGA", "HANNAH", and "RACECAR".
Given a String word, calculate the number of unique palindromes that can be made out of the characters in word, using each character exactly once (see examples).
Definition
- Class:
- Palindromes
- Method:
- count
- Parameters:
- String
- Returns:
- int
- Method signature:
- int count(String word)
- (be sure your method is public)
Constraints
- word has length between 1 and 17, inclusive.
- word will contain only capital letters ('A'-'Z').
Examples
"ABB"
Returns: 1
The only palindrome is "BAB"."ABBA"
Returns: 2
The two legal palindromes are "ABBA" and "BAAB"."AMBSEAMBS"
Returns: 24
"ABC"
Returns: 0
"AABBCCDDEEFFGGHHI"
Returns: 40320