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 rest of the letters are lowercase.
Given a CamelCase sequence represented as a string. The task is to find the number of words in the CamelCase sequence.
Input : str = "geeksForGeeks" Output : 3 Input : str = "iGotAnInternInGeeksForGeeks" Output : 8
Approach: As it is already known that the sequence is CamelCase, so it can be said that the number of words in the sequence will be one more than the number of uppercase letters.
- Iterate the sequence from the 2nd letter to the end of the sequence.
- No. of words will be equal to uppercase letters+1 during the 1st step iteration.
Below is the implementation of the above approach:
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.
- Print all words matching a pattern in CamelCase Notation Dictonary
- CamelCase Pattern Matching
- Check if the given string of words can be formed from words present in the dictionary
- Count words that appear exactly two times in an array of words
- Given a sequence of words, print all anagrams together | Set 2
- Given a sequence of words, print all anagrams together | Set 1
- Given a sequence of words, print all anagrams together using STL
- Find a valid parenthesis sequence of length K from a given valid parenthesis sequence
- Convert an unbalanced bracket sequence to a balanced sequence
- Print number of words, vowels and frequency of each character
- Reverse String according to the number of words
- Count the number of words having sum of ASCII values less than and greater than k
- Sort an Array alphabetically when each number is converted into words
- Print all valid words that are possible using Characters of Array
- Put spaces between words starting with capital letters
- Program to extract words from a given String
- Count words present in a string
- Reverse words in a given String in Java
- Sorting array of strings (or words) using Trie
- Check if a two character string can be made using given words
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.