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 or 2 letters, change all letters to lowercase.
	Otherwise, change the first letter to uppercase and the remaining letters to lowercase.


Return the capitalized title.

&nbsp;
Example 1:

Input: title = "capiTalIze tHe titLe"
Output: "Capitalize The Title"
Explanation:
Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.


Example 2:

Input: title = "First leTTeR of EACH Word"
Output: "First Letter of Each Word"
Explanation:
The word "of" has length 2, so it is all lowercase.
The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.


Example 3:

Input: title = "i lOve leetcode"
Output: "i Love Leetcode"
Explanation:
The word "i" has length 1, so it is lowercase.
The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.


&nbsp;
Constraints:


	1 &lt;= title.length &lt;= 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.


class Solution:
    def capitalizeTitle(self, title: str) -> str:
        li = title.split()
        for i,l in enumerate(li):
            if len(l) <= 2:
                li[i] = l.lower()
            else:
                li[i] = l[0].upper() + l[1:].lower()
        return ' '.join(li)
class Solution {
	public String capitalizeTitle(String title) {

		char[] ch = title.toCharArray();
		int len = ch.length;

		for(int i = 0; i < len; ++i) {

			int firstIndex = i; // store the first index of the word

			while(i < len && ch[i] != ' ') {
				ch[i] = Character.toLowerCase(ch[i]); // converting the character at ith index to lower case ony by one
				++i;
			}
			
			// if word is of length greater than 2, then turn the first character of the word to upper case
			if(i - firstIndex > 2) {
				ch[firstIndex] =  Character.toUpperCase(ch[firstIndex]); // converting the first character of the word to upper case
			}
		}

		return String.valueOf(ch); // return the final result by converting the char array into string
	}
}
class Solution {
public:
    string capitalize(string s){
        transform(s.begin(), s.end(), s.begin(), ::tolower);
        if(s.length() <= 2){
            return s;
        }
        s[0] = s[0] - 'a' + 'A';
        return s;
    }
    string capitalizeTitle(string title) {
        string str = "";
        string ans = "";
        for(int i = 0; i < title.length(); i++){
            if(title[i] != ' '){
                str.push_back(title[i]);
            }
            else{
                str = capitalize(str);
                ans += str + " ";
                str = "";
            }
        }
        str = capitalize(str);
        ans += str;
        return ans;
    }
};
var capitalizeTitle = function(title) {
    const words = title.toLowerCase().split(' ');
    
    for (let i = 0; i < words.length; i++) {
        if (words[i].length > 2) {
            words[i] = words[i][0].toUpperCase() + words[i].slice(1);
        }
    }
    
    return words.join(' ');
};
Capitalize the Title