TopcoderArchive
SRM25 Oct 2006
SRM 324

Alliteration

Problem statement, definition, constraints, and public examples.

Problem Statement

An alliteration consists of two or more consecutive words which start with the same letter (ignoring case). You are given a sequence of words. Find out the number of alliterations in this sequence, considering only alliterations which cannot be extended.

Definition

Class:
Alliteration
Method:
count
Parameters:
String[]
Returns:
int
Method signature:
int count(String[] words)
(be sure your method is public)

Constraints

  • words will contain between 1 and 50 elements, inclusive.
  • Each element of words will contain between 1 and 50 letters ('a'-'z', 'A'-'Z'), inclusive.

Examples

  1. {"He", "has", "four", "fanatic", "fantastic", "fans"}
    Returns: 2
    The first two words are an alliteration, and the last four words are another alliteration.
  2. {"There", "may", "be", "no", "alliteration", "in", "a", "sequence"}
    Returns: 0
    This sequence of words contains no alliteration.
  3. {"Round", "the", "rugged", "rock", "the", "ragged", "rascal", "ran"}
    Returns: 2
Back to all problems