Given a string in Camel Case format, we need to extract all the words which are present in the string.
CamelCase is the sequence of one or more than one words having the following properties:
- It is a concatenation of one or more words consisting of English letters.
- All letters in the first word are lowercase.
- For each of the subsequent words, the first letter is uppercase and the rest of the letters are lowercase.
Input: str = “GeeksForGeeks”
Input: str = “AComputerSciencePortalForGeeks”
A simple approach is to traverse the array and extract every word by looking at its first character, as it will always be in upper-case. Store all extracted words in a new array and print them.
Geeks For Geeks
Time Complexity: O(N)
Space Complexity: O(N), as we needed a new array to store output.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.