HiddenMessage
SRM 316 · 2006-08-19 · by _efer_
Problem Statement
Some texts contain hidden messages. In the context of this problem, the hidden message of a text is composed of the first letter from each word in the text, in the order they appear.
Given a
Constraints
- text will contain between 1 and 50 characters, inclusive.
- Each character of text will be either a lowercase letter ('a'-'z'), or a space (' ').
"compete online design event rating" Returns: "coder"
Taking the first letter from each word yields the return "coder".
" c o d e r " Returns: "coder"
Watch out for the leading spaces.
"round elimination during onsite contest" Returns: "redoc"
"coder" written backwards.
" hello world " Returns: "hw"
"the quick brown fox jumped over the lazy dog " Returns: "tqbfjotld"
" " Returns: ""
Since there are no words here, the empty string must be returned.
Submissions are judged against all 39 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class HiddenMessage with a public method string getMessage(string text) · 39 test cases · 2 s / 256 MB per case