Count Capitalized Words
sentence is a line of words separated by single spaces, with no space at either end. It may also be the empty string, which holds no words.
A word is capitalized when its first character is an uppercase letter A to Z; the rest of the word does not matter, so NASA and Tom's are both capitalized while iPhone and 3rd are not. Return how many words of sentence are capitalized.
Example 1
sentence "The Quick brown Fox"
returns 3
The, Quick and Fox start with an uppercase letter; brown does not.
Example 2
sentence "hello world"
returns 0
No word starts with an uppercase letter.
Constraints
0 <= len(sentence) <= 60- words have letters, digits and apostrophes only, and are separated by single spaces
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Count Differing PositionsBeginner
- Count Prefixes of a Given StringBeginner
- Defanging an IP AddressBeginner
- Determine if String Halves Are AlikeBeginner
- Find Words Containing CharacterBeginner
- Join the Non-Empty PartsBeginner
- Longest Vowel RunBeginner
- Longest Word in a SentenceBeginner