Problem Statement
You are given String s, consisting of all upper-case letters. A double-letter refers to two adjacent letters in the string being the same. Return the number of double-letters appearing in s.
Definition
- Class:
- DoubleLetterCount
- Method:
- count
- Parameters:
- String
- Returns:
- int
- Method signature:
- int count(String s)
- (be sure your method is public)
Constraints
- s will contain between 1 and 50 characters, inclusive.
- Each character in s will be an upper-case ('A'-'Z') letter.
- s will not contain any triple-letters.
Examples
"MISS"
Returns: 1
The SS is a double letter."COMMITTEE"
Returns: 3
M, T, and E all form double letters."AABAAC"
Returns: 2
Notice that we count both instances of AA."ABCDEFG"
Returns: 0
No double letters here."AXXBCYWWYDEFZZ"
Returns: 3