Given a string sentence, return the same sentence with the first letter of each word in upper case.
The words are separated by single spaces, and the sentence doesn't start or end with a space. Only the first character of each word changes: the rest of the word stays exactly as it is, even when it has upper-case letters. A first character that has no upper case, like a digit, stays as it is too.
Example 1:
Input: sentence = "hello world" Output: "Hello World" Explanation: h becomes H and w becomes W.
Example 2:
Input: sentence = "learn to code with AlgoCademy" Output: "Learn To Code With AlgoCademy" Explanation: AlgoCademy already starts with an upper-case letter, so it stays the same.
Example 3:
Input: sentence = "iPhone and NASA" Output: "IPhone And NASA" Explanation: Only the first character of each word changes: "Phone" and "ASA" stay as they were.
Constraints:
sentencehas at least one word.sentencecontains English letters, digits and apostrophes, with single spaces between the words.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
