Statistics

Problem Statement for "DoubleLetterCount"

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

  1. "MISS"

    Returns: 1

    The SS is a double letter.

  2. "COMMITTEE"

    Returns: 3

    M, T, and E all form double letters.

  3. "AABAAC"

    Returns: 2

    Notice that we count both instances of AA.

  4. "ABCDEFG"

    Returns: 0

    No double letters here.

  5. "AXXBCYWWYDEFZZ"

    Returns: 3

  6. "HWMUGFQLEJXCJRMSZGUZSADXALKVNKBHEHWGSURZNCDPMUZMYJ"

    Returns: 0

  7. "VXRSJLECMAJEDNIXYTYXFSLFTWDRQTKNGNKOGDUIFHTQGIANOH"

    Returns: 0

  8. "TLLKSCLLZNINMSPVYPDUQUZPSXZVZLVQCIZZCVVHDUEHZSVAAL"

    Returns: 5

  9. "JLJTQZLVRUDPLORSKDTQSCUVRWPSQACYVOBKGISANHDAENJQPH"

    Returns: 0

  10. "HRHJSGQOCUJTFRSFUXMHLBLTCKYTREMZCISKRLWUTSGXQTCMIY"

    Returns: 0

  11. "CFMAKJLMUDLRLYZVLEMHPVKNCLEMEQWMYVFCALHBPIAJZMRFOR"

    Returns: 0

  12. "LRVIRHUYXZEYHDGZTQSWVAWLRGUBOPUZXNFERPDYIBNIXRAXCA"

    Returns: 0

  13. "MIM"

    Returns: 0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: