Connection Status:
Competition Arena > Normalizer
SRM 90 · 2002-05-21 · by mitalub
Class Name: Normalizer
Return Type: String
Method Name: normalize
Arg Types: (string)
Problem Statement

Problem Statement

An online registration system must check that the registrants' user names are unique. The user names are allowed to contain numbers, capital and lowercase letters, and spaces. However, the system must be made so that the normalized forms of all user names are unique.

The normalized form of a user name is the form in which all spaces are removed and all capital letters are converted to lower case.

Thus the user names "username" and "Us Er Na Me" do not have unique normalized forms.

You are to write a class Normalizer which contains a method normalize. The method takes a String that is a user name as a parameter and returns the normalized form of the user name.

Constraints

  • userName contains between 1 and 50 characters, inclusive.
  • userName contains at least 1 non-space character.
  • userName contains lowercase and capital letters, digits, and spaces (a-z, A-Z, 0-9).
Examples
0)
"  thIS1201982 Is a TEst"
Returns: "this1201982isatest"
1)
"        K     "
Returns: "k"
2)
" 1 1 1"
Returns: "111"
3)
" HiHoWaRe YOU"
Returns: "hihowareyou"
4)
"nochangehere"
Returns: "nochangehere"

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

Coding Area

Language: C++17 · define a public class Normalizer with a public method string normalize(string userName) · 28 test cases · 2 s / 256 MB per case

Submitting as anonymous