Connection Status:
Competition Arena > ChatTranscript
SRM 249 · 2005-06-29 · by AdminBrett · Simple Search, Iteration
Class Name: ChatTranscript
Return Type: int
Method Name: howMany
Arg Types: (vector<string>, string)
Problem Statement

Problem Statement

You have received the transcript of an online chat. Each element of transcript corresponds to a line. You want to know how many times name said something. To do this, count how many lines begin with name immediately followed by a colon. This comparison is case sensitive.

Constraints

  • transcript will contain between 1 and 50 elements inclusive.
  • Each element of transcript will contain between 1 and 50 characters inclusive.
  • Each character in each element of transcript will have ASCII value between 32 and 126 inclusive.
  • name will contain between 1 and 50 characters inclusive.
  • Each character in name will be a letter (A-Z, a-z) or a digit (0-9).
Examples
0)
{
"Bob: Hello Tim.",
"Tim: Hello Bob.",
"Bob: How are ya Tim?",
"Frank: Stop chatting!"
}
"Bob"
Returns: 2

Bob managed to say two things before Frank entered the conversation.

1)
{
"Bob: This is a long",
"sentence that takes 2 lines.",
"Tim: Yes it is.",
"Bob : I am not Bob.",
"Frank: No you aren't!",
" Bob: Neither am I."
}
"Bob"
Returns: 1

Only one line begins with "Bob:" (quotes for clarity).

2)
{
"Crazy1010: !@LK%#L%K @#L%K @#L%K@#L%K2kl53k2",
"Bob: You are crazy.",
"Crazy1010 Yup #@LK%$L!K%LK%!K% !K afmas,"
}
"Crazy1010"
Returns: 1
3)
{
"A:A:A:A:A:A:A:A:A",
"b:b:b:b:b:b:b:b:b"
}
"B"
Returns: 0
4)
{"A:A:A:A:A:A:A:A:A"}
"A"
Returns: 1

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

Coding Area

Language: C++17 · define a public class ChatTranscript with a public method int howMany(vector<string> transcript, string name) · 38 test cases · 2 s / 256 MB per case

Submitting as anonymous