PROBLEM STATEMENT
You are a very practical person and do not see the purpose of having repeated
consecutive letters. For example, you feel the word "occurrence" should have
only two occurrences of 'c' and one of 'r'. Wouldn't it be a lot easier to
just write "ocurence"? Those extra letters seem to serve no purpose except to
make the word bigger. You wonder in an average String, how many letters occur
consecutively. So you decide to implement a method numRepeats, which returns
the number of letters that occur consecutively in a given String.
DEFINITION
Class: Repeats
Method name: numRepeats
Parameters: String
Return type: int
Method signature (be sure your method is public): int numRepeats (String s);
NOTES
* The case of the letters does not matter - so "Aardvark" is considered to have
repeated 'a'.
* If a letter appears consecutively more than once, only count it as one
towards the return value. So "mississippi" would return 2 because the "s" and
"p" repeat.
* Don't count consecutive spaces as consecutive letters. So "Hi My name is
Jon" returns 0.
TopCoder will ensure that:
- The length of s is between 0 and 50, inclusive.
- The only characters in s will be a-z, A-Z, and the space character.
EXAMPLES
1. If s = "Aardvard",
"a" is the only letter that occurs consecutively so return 1.
2. If s = "mississippi",
"s" occurs consecutively twice and "p" occurs consecutively once. Return 2.
3. If s = "Schwarzenegger", return 1.
4. If s = "Read my lips No new taxes", return 0.
5. If s = "This StuffStinks", return 1.
6. If s = "ryyy", return 1.