Problem
Take the first letter of each word in full_name, uppercase it, and join the letters. Words are separated by one or more spaces.
Implement initials(full_name).
Input
full_name: A name made of letters and spaces.
Output
Return the initials, for example "ADL".
Constraints
1 ≤ length of full_name ≤ 200; it contains at least one letter
Examples
Input:
full_name = "Ada Lovelace"
Expected output:
expected = "AL"
Input:
std::string full_name = "Ada Lovelace";
Expected output:
std::string expected = "AL";
Input:
string full_name = "Ada Lovelace";
Expected output:
string expected = "AL";
Explanation
A from Ada and L from Lovelace: "AL".
Input:
full_name = "grace brewster hopper"
Expected output:
expected = "GBH"
Input:
std::string full_name = "grace brewster hopper";
Expected output:
std::string expected = "GBH";
Input:
string full_name = "grace brewster hopper";
Expected output:
string expected = "GBH";
Explanation
Extra spaces don't matter; the initials are uppercased: "GBH".
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
Each word contributes exactly one character: its first letter.
Hint 2
Traverse the name while tracking when a new word starts after spaces.
Hint 3
Watch for multiple spaces in a row so you only take one initial per word.
Expected complexity
O(n) time, O(1) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.