TitleString
SRM 210 · 2004-09-01 · by the_one_smiley
SRM 210 · 2004-09-01 · by the_one_smiley · String Manipulation, String Parsing
Problem Statement
Problem Statement
A common word-processing task is capitalizing the first letter of each word in a title. Write a class TitleString with a method toFirstUpperCase that takes a String title containing lowercase words separated by one or more space characters and returns a String that is identical to title except with the first character of each word capitalized.
Notes
- title may have leading or trailing spaces.
Constraints
- title will contain between 0 and 50 characters, inclusive.
- Each character of title will either be a space or a lowercase letter ('a' to 'z').
Examples
0)
"introduction to algorithms" Returns: "Introduction To Algorithms"
1)
"more than one space between words" Returns: "More Than One Space Between Words"
2)
" lord of the rings the fellowship of the ring " Returns: " Lord Of The Rings The Fellowship Of The Ring "
3)
" " Returns: " "
4)
"i" Returns: "I"
Submissions are judged against all 55 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class TitleString with a public method string toFirstUpperCase(string title) · 55 test cases · 2 s / 256 MB per case