Easy 0 solved 0% acceptance

Title Case

Capitalize the first letter of every word.

Problem

Convert 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.

Constraints

0 ≤ length ≤ 10,000 (letters and spaces)

Examples

Example 1
Input:
text = "hello world"

Expected output:
expected = "Hello World"
Input:
std::string text = "hello world";

Expected output:
std::string expected = "Hello World";
Input:
string text = "hello world";

Expected output:
string expected = "Hello World";

Explanation

"hello" → "Hello" and "world" → "World".

Example 2
Input:
text = "tHE qUICK fox"

Expected output:
expected = "The Quick Fox"
Input:
std::string text = "tHE qUICK fox";

Expected output:
std::string expected = "The Quick Fox";
Input:
string text = "tHE qUICK fox";

Expected output:
string expected = "The Quick Fox";

Explanation

Remaining letters become lowercase: "The Quick Fox".

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.