VOOZH about

URL: https://www.geeksforgeeks.org/dsa/put-spaces-words-starting-capital-letters/

⇱ Put spaces between words starting with capital letters - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Put spaces between words starting with capital letters

Last Updated : 23 Jul, 2025

You are given an array of characters which is basically a sentence. However, there is no space between different words and the first letter of every word is in uppercase. You need to print this sentence after following amendments: 

  1. Put a single space between these words. 
  2. Convert the uppercase letters to lowercase.

Examples:

Input : BruceWayneIsBatman
Output : bruce wayne is batman
Input : You
Output : you
Recommended Practice

We check if the current character is in uppercase then print " "(space) and convert it into lowercase. 

Implementation:


Output
bruce wayne is batman






Time complexity:O(n)
Auxiliary Space: O(1)

Put spaces between words starting with capital letters using Regex.


Output
bruce wayne is batman







Time complexity: O(n)
Auxiliary Space: O(n)

Comment
Article Tags:
Article Tags: