Connection Status:
Competition Arena > VLNString
SRM 226 · 2005-01-05 · by the_one_smiley · String Manipulation, String Parsing
Class Name: VLNString
Return Type: String
Method Name: makeAcronym
Arg Types: (string)
Problem Statement

Problem Statement

An acronym is a sequence of characters that is used to refer to something with a very long name. An acronym is generated from a long name by capitalizing the first letter of every word in the name and concatenating them together. There are three exceptions: the common words "and", "the", and "of" are ignored when generating the acronym. In this problem, a word is defined as one or more non-space characters preceded by either a space or the beginning of the string and followed by either a space or the end of the string. Write a class VLNString with a method makeAcronym that takes a String longName and returns a String with its acronym generated as described above.

Notes

  • longName may contain leading and trailing spaces, and there may be more than one space between words.
  • The return value may be an empty string.

Constraints

  • longName will contain between 1 and 50 characters, inclusive.
  • longName will contain only lowercase English letters ('a' to 'z') and space characters.
Examples
0)
"dance dance revolution"
Returns: "DDR"
1)
"  return  of  the king   "
Returns: "RK"
2)
"the united states of america"
Returns: "USA"
3)
" of  the   and    "
Returns: ""
4)
"s p a m"
Returns: "SPAM"

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

Coding Area

Language: C++17 · define a public class VLNString with a public method string makeAcronym(string longName) · 61 test cases · 2 s / 256 MB per case

Submitting as anonymous