TopCoder problem "Alliteration" used in SRM 324 (Division II Level One)



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

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

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=6808

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10004&pm=6808

Writer:

AdrianKuegel

Testers:

PabloGilberto , brett1479 , Cosmin.ro , Olexiy

Problem categories:

Simple Search, Iteration