Problema
Ver traducciónConvert text to title case: the first letter of every word becomes uppercase and the remaining letters lowercase. Words are separated by single spaces.
Implement title_case(text).
Input
text: Lowercase or mixed-case words separated by single spaces.
Output
Return the title-cased text.
Restricciones
0 ≤ length ≤ 10,000 (letters and spaces)
Ejemplos
Entrada:
text = "hello world"
Salida esperada:
expected = "Hello World"
Entrada:
std::string text = "hello world";
Salida esperada:
std::string expected = "Hello World";
Entrada:
string text = "hello world";
Salida esperada:
string expected = "Hello World";
Explicación
"hello" → "Hello" and "world" → "World".
Entrada:
text = "tHE qUICK fox"
Salida esperada:
expected = "The Quick Fox"
Entrada:
std::string text = "tHE qUICK fox";
Salida esperada:
std::string expected = "The Quick Fox";
Entrada:
string text = "tHE qUICK fox";
Salida esperada:
string expected = "The Quick Fox";
Explicación
Remaining letters become lowercase: "The Quick Fox".
Referencias
Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.