2129. Capitalize the Title
Easy
You are given a string title
consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:
If the length of the word is
1
or2
letters, change all letters to lowercase.Otherwise, change the first letter to uppercase and the remaining letters to lowercase.
Return the capitalized title
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= title.length <= 100
title
consists of words separated by a single space without any leading or trailing spaces.Each word consists of uppercase and lowercase English letters and is non-empty.
解題
Last updated