← All coding problems
Capitalise Each Word
easyPlacement Coding+10 XPTime limit 2s
Rewrite a sentence so that every word starts with a capital letter and the rest of the word is in lowercase. wELCOME to sKILLS becomes Welcome To Skills.
Input: one line — words made of English letters, separated by single spaces.
Output: the sentence in title case.
Constraints: 1 ≤ length ≤ 10⁵.
Think about it: a character starts a word when it is the first character or the character before it is a space. Upper-case those, lower-case everything else.
Sample input 1
wELCOME to sKILLS
Sample output 1
Welcome To Skills
Sample input 2
java
Sample output 2
Java
Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).