Connection Status:
Competition Arena > DoubleLetterCount
Rookie SRM 11 · 2022-03-24 · by erinn · Brute Force
Class Name: DoubleLetterCount
Return Type: int
Method Name: count
Arg Types: (string)
Problem Statement

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.

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
0)
"MISS"
Returns: 1

The SS is a double letter.

1)
"COMMITTEE"
Returns: 3

M, T, and E all form double letters.

2)
"AABAAC"
Returns: 2

Notice that we count both instances of AA.

3)
"ABCDEFG"
Returns: 0

No double letters here.

4)
"AXXBCYWWYDEFZZ"
Returns: 3

Submissions are judged against all 13 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class DoubleLetterCount with a public method int count(string s) · 13 test cases · 2 s / 256 MB per case

Submitting as anonymous