TopcoderArchive
Archive
Algorithm problem

PalindromesAnalyzer

Problem statement, definition, constraints, and public examples.

Problem Statement

A palindrome is a string that reads the same forward and backward. The PalMeasure of a string is the sum of the lengths of its substrings that are palindromes. Return the PalMeasure of the concatenation of all the strings in the String[] text.

Definition

Class:
PalindromesAnalyzer
Method:
summaryLength
Parameters:
String[]
Returns:
long
Method signature:
long summaryLength(String[] text)
(be sure your method is public)

Notes

  • A substring is a sequence of consecutive characters from a string.
  • An entire string counts as a substring of itself.
  • Count equal substrings which have different positions as different. For example, if text = {"AAA"}, return 10.

Constraints

  • text will contain between 1 and 50 elements, inclusive.
  • Each element of text will contain only uppercase letters ('A'-'Z').
  • Each element of text will contain between 1 and 50 characters, inclusive.

Examples

  1. {"AAA"}
    Returns: 10
  2. {"AB"}
    Returns: 2
  3. {"AB", "BA"}
    Returns: 10
  4. {"AB", "AAA"}
    Returns: 15
  5. {"AZ", "ZZ", "A"}
    Returns: 17
Back to all problems