Leetcode Problem 2129. Capitalize the Title

2129. Capitalize the Title

Leetcode Solutions

Iterative Word Processing

  1. Split the input string title into a list of words.
  2. Iterate over each word in the list.
  3. Check the length of the current word.
    • If the length is 1 or 2, convert the word to lowercase.
    • If the length is greater than 2, convert the first letter to uppercase and the rest to lowercase.
  4. Join the processed words with a space to form the final string.
  5. Return the capitalized title.
UML Thumbnail

Character-by-Character Processing

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...